我有两次,例如启动时间为上午9点,结束时间为下午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"));