/**
* 获取两个日期之间的所有日期
* @param string $start
* @param string $end
* @return array
*/
function getPrDates($start, $end)
{
$list = [];
$dt_start = strtotime($start);
$dt_end = strtotime($end);
while ($dt_start <= $dt_end) {
$list[] = date('Y-m-d', $dt_start);
$dt_start = strtotime('+1 day', $dt_start);
}
return $list;
}
示例
print_r(getPrDates('2018-10-30', '2018-11-10'));
结果
Array
(
[0] => 2018-10-30
[1] => 2018-10-31
[2] => 2018-11-01
[3] => 2018-11-02
[4] => 2018-11-03
[5] => 2018-11-04
[6] => 2018-11-05
[7] => 2018-11-06
[8] => 2018-11-07
[9] => 2018-11-08
[10] => 2018-11-09
[11] => 2018-11-10
)
非特殊说明,本博所有文章均为博主原创。
如若转载,请注明出处:https://www.ihulang.com/index/info/4.html