0

例如,我有两次启动时间为上午 9 点,结束时间为下午 1 点,我从下拉列表中获得了两次。如何仅以小时为单位找到这两次之间的差异。

4

1 回答 1

1
$to_time = strtotime("09:00:00");
$from_time = strtotime("13:00:00");
echo round(abs($to_time - $from_time) / 60 / 60 ,2). " Hours";

如果您不确定是否可以使用 24 小时格式转换您的时间

$time_in_24_hour_format  = date("H:i", strtotime("1:00 PM"));
于 2013-07-17T00:21:33.313 回答