<?php function getDateFromRange($startdate, $enddate){ $stimestamp = strtotime($startdate); $etimestamp = strtotime($enddate); // 计算日期段内有多少天 $days = ($etimestamp-$stimestamp)/86400+1; // 保存每天日期 $date = array(); for($i=0; $i<$days; $i++){ $date[] = date('Y-m-d', $stimestamp+(86400*$i)); } return $date; } $arr=getDateFromRange('2021-02-01','2021-03-01'); foreach ($arr as $key => $value) { echo $value.'<br/>'; } ?>
0条评论