話很少說,源碼奉上!數組
function getDateRange($startdate, $enddate) { $stime = strtotime($startdate); $etime = strtotime($enddate); $datearr = []; while ($stime <= $etime) { $datearr[] = date('Y-m-d', $stime);//獲得dataarr的日期數組。 $stime = $stime + 86400; } return $datearr; } $dates=getDateRange('2016-1-1','2016-1-6'); print_r($dates);