【发布时间】:2020-05-17 19:21:55
【问题描述】:
我需要在 PHP 中显示两次之间的差异我使用 strtotime() 函数将我的时间转换为整数,但我的问题是结果与我的预期不符
<?php
$hour1 = '12:00:00';
$hour2 = '9:00:00';
$avg = strtotime($hour1) - strtotime($hour2);
$result = date('h:i:s', $avg); // result = 06:30:00 what I expected is 3:00:00
但是相差3:00:00这个怎么算?
【问题讨论】:
-
strtotime()和date似乎不是这项工作的正确工具。