【发布时间】:2012-10-21 22:56:03
【问题描述】:
我的时间格式是 d/m/Y - h:ia
示例输出是 21/10/2012 - 03:49pm
我正在使用这段代码来计算 $from 和 $to 之间的差异
$to = strtotime("21/10/2012 - 10:30pm");
$from = strtotime("22/10/2012 - 8:30am");
$stat = date("H\h:i\m", abs($to - $from));
但我总是得到不正确的值
对于上面的示例,我得到了 16h:00m 的输出,但它应该是 10h:00m
有没有更有效的方法来做到这一点?
【问题讨论】:
-
date() 的结果取决于您的时区。请改用 gmtime() 来避免这种情况。
-
请不要重复同一个问题,你之前的问题有可能的答案。
-
该问题的时间日期格式不正确