Date function to display all dates between two dates

前端 未结 3 1872
粉色の甜心
粉色の甜心 2020-12-06 11:39

Is there any PHP function to display all dates between two dates?

3条回答
  •  粉色の甜心
    2020-12-06 12:34

    You can check out this function also

            $day = 86400; // Day in seconds  
            $format = 'Y-m-d'; // Output format (see PHP date funciton)  
            $sTime = strtotime($start_date); // Start as time  
            $eTime = strtotime($end_date); // End as time  
            $numDays = round(($eTime - $sTime) / $day) + 1;  
            $days = array();  
    
            for ($d = 0; $d < $numDays; $d++) {  
                $days[] = date($format, ($sTime + ($d * $day)));  
            }  
    

提交回复
热议问题