尝试获取两个DateTime对象之间的差异。使用下面的代码,我可以回显$endSub
变量并获得类似2012-5-26T00:00:00-04:00
的字符串,这正是我需要的。但是,如果exit()
行上没有$interval =
代码,则会在标题中显示错误。任何人都可以看到这种情况发生的原因吗?
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);
答案 0 :(得分:3)
startSub
变量来自何处?它肯定是原始的或无效的。