I want to get the date between two dates excluding last date, following code i will used to find dates. But it trigger an error saying:
Class 'DateInterval' not found
Code:
$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);
See Question&Answers more detail:os