我想获取两个日期之间的日期,不包括最后一个日期,下面的代码我将用来查找日期。但它触发了一个错误说:
找不到类“DateInterval”
代码:
$start = new DateTime('2014-08-06');
$end = new DateTime('2014-09-06');
$oneday = new DateInterval("P1D");
$days = array();
$data = "7.5";
foreach(new DatePeriod($start, $oneday, $end->add($oneday)) as $day) {
$day_num = $day->format("N");
if($day_num < 6) {
$days[$day->format("Y-m-d")] = $data;
}
}
print_r($days);