如何以“HH:mm:ss”格式从两个给定时间获得总小时数?
这是我的代码:
$start = 01:00:00 PM;
$end = 02:00:00 PM;
预期产出:
$total = 1;
答案 0 :(得分:5)
您可以尝试这样:
$start = new DateTime('01:00:00 PM');
$end = new DateTime('02:00:00 PM');
$diff = $start->diff($end);
echo $diff->format('%H');