两个日期之间的所有时间
程序员文章站
2022-03-14 09:01:30
...
function DateRange ($begin,$end,$interval='M'){ $begin = new DateTime($begin); $end = new DateTime($end); $end = $end->modify('+1 day'); $t ='P1'.$interval; $interval = new DateInterval($t); $daterange = new DatePeriod($begin, $interval ,$end); foreach($daterange as $date){ $range[]= $date->format("Ymd"); } return $range; }