php获取指定日期段内每一天的日期和天数
function getDateFromRange($startdate, $enddate,$format='Y-m-d'){
$startdate = date($format.' 00:00:00',strtotime($startdate));
$enddate = date($format.' 23:59:59',strtotime($enddate));
$stimestamp = strtotime($startdate);
$etimestamp = strtotime($enddate);
if($etimestamp<$stimestamp) return [];
$days = (int)ceil(($etimestamp-$stimestamp)/86400);
$date = array();
for($i=0; $i<$days; $i++){
$date[] = date($format, $stimestamp+(86400*$i));
}
$data = [
'dates' => $date,
'days' => $days,
];
return $data;
}