如何在PHP 5.2中将DateTime :: diff()与DateTime :: format(\'%R\')结合使用?
|
关于DateTime :: diff()有很多问题(和解决方案),但是我没有找到以下代码的任何解决方案:
$start = new DateTime(\'13:00\');
$end = new DateTime(\'02:00\');
$difference = $start->diff($end);
if ($difference->format(\'%R\') === \'-\')
{
$passedMidnight = true;
}
else
{
$passedMidnight = false;
}
这基本上就是我在PHP 5.2中寻找的东西:一种与$ start相比,找出$ end是否在午夜过去的方法。
没有找到相关结果
已邀请:
3 个回复
芯伶句餐绕
我看不到这种情况不起作用的情况,因为DST通常将时钟在凌晨2点移动(对吗?)。
窝头菊
校勒魏寡