尝试减去两次:
$obtime = "2310";
$runtime = "0048";
$run=new DateTime($runtime);
$ob=new DateTime($obtime);
$interval= $run->diff($ob);
$age=$interval->format('%H%I');
print "Age is: $age\n";
上面会输出 2222,意思是 22 小时 22 分钟的差异。当然,我们知道时钟是前进的,而 0048 距离 2310 仅 1 小时 38 分。
有没有更好的方法来查找两个“24 小时”时间之间的时差?