php get each day's date within the period specified date

/**
 * Get each day's date within the period specified date
 * @Param Date $ startdate start date
 * @Param Date $ enddate end date
 * @return Array
 */
function getDateFromRange($startdate, $enddate){

    $stimestamp = strtotime($startdate);
    $etimestamp = strtotime($enddate);

    // calculate the date segments within how many days
    $days = ($etimestamp-$stimestamp)/86400+1;

    // Save the Date day
    $date = array();

    for($i=0; $i<$days; $i++){
        $date[] = date('Y-m-d', $stimestamp+(86400*$i));
    }

    return $date;
}

Guess you like

Origin www.cnblogs.com/ssx314/p/11563942.html