<?php $begin = new DateTime( '2012-08-01' ); $end = new DateTime( '2012-08-08' ); $end = $end->modify( '+1 day' ); $interval = new DateInterval('P1D'); $daterange = new DatePeriod($begin, $interval ,$end); foreach($daterange as $date){ echo $date->format("Y-m-d") . "<br>"; } ?>
Thinkphp方式
<?php $interval = new DateInterval('P1D'); $starttime = new DateTime($start_time); $endtime = new DateTime($end_time); $endtimerel = $endtime->modify('+1 day'); $dateranges = new DatePeriod($starttime, $interval, $endtimerel); foreach ($dateranges as $datev) { $daylang = $datev->format('Y-m-d'); echo $daylang; } ?>