且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

计算两个时间戳之间的总小时数

更新时间:2023-01-30 10:54:15

这解决了您的问题:

This solves your problem:

$start = explode(':', $start_time);
$end = explode(':', $end_time);
$total_hours = $end[0] - $start[0] - ($end[1] < $start[1]);

请参阅此键盘作为证明。

此解决方案假定两个小时都是同一天。

This solution assumes both hours are from the same day.