我想减去两个小时:
一个。 40:00:00 湾31:18:00
我希望这个结果09:42:00。我怎样才能做到这一点?
答案 0 :(得分:1)
结果是08:42:00(40:00:00-31:18:00 = 08:42:00而不是09:42:00)
我认为这解决了:
$lasthour = '40:00:00';
$firsthour = '31:18:00';
//explode first hour
list($h, $m, $s) = explode(':', $firsthour);
//convert to seconds
$secFh = ($h * 3600 + $m * 60 + $s);
//explode last hour
list($h, $m, $s) = explode(':', $lasthour);
//convert to seconds
$secLh = ($h * 3600 + $m * 60 + $s);
$sub = $secLh - $secFh;
echo gmdate("H:i:s", $sub);