我有以下代码:
$dStart = new DateTime('2013-03-15'); $dEnd = new DateTime('2013-04-01'); $dDiff = $dStart->diff($dEnd); echo $dDiff->days;
我不知道为什么我得到6015结果.
试试吧
原文链接:https://www.f2er.com/php/136725.html$dStart = strtotime('2013-03-15'); $dEnd = strtotime('2013-04-01'); $dDiff = $dEnd - $dStart; echo date('H:i:s',$dDiff);
或根据您的代码尝试
$dDiff = $dStart->diff($dEnd); $date->format('d',$dDiff); echo $dDiff->days;
如果你想在几天内进行差异,也可以试试这个
echo floor($dDiff/(60*60*24));