1、枚举两个日期中间的所有日期
<?php function prDates($start, $end) { $dt_start = strtotime($start); $dt_end = strtotime($end); $temp = []; while ($dt_start <= $dt_end) { $re = date('Y-m-d', $dt_start); $temp[] = $re; $dt_start = strtotime('+1 day', $dt_start); } return $temp; // 返回data型数据 }
2、获取两个日期之间的天数
<?php function countData($Date_1, $Date_2) { $d1 = strtotime($Date_1); $d2 = strtotime($Date_2); $Days = ($d1 - $d2) / 3600 / 24; return $Days; // 返回int型数据 }