Trying to get the difference between two DateTime objects. With the below code, I can echo out the $endSub variable and get a string like 2012-5-26T00:00:00-04:00 which is exactly what I need. However, I get the error in the title if I do not exit() the code on the $interval = line. Can anyone see a reason this would occur?
if ($todays_month >= 6){
$endSub = new DateTime(($startYear+1).'-5-'.$startDay);
}else{
$endSub = new DateTime($startYear.'-5-'.$startDay);
}
echo $endSub->format(DATE_RFC3339);
exit();
$interval = $startSub->diff($endSub);
where did the
startSubvariable come from? its surely a primitive or null.