【发布时间】:2016-02-16 20:46:14
【问题描述】:
我发现这两个返回不同的数字 - 但都应该给出时间戳。
strtotime( date("Y-m-d h:i:s") ); //currently 1447570497
time(); //currently 1447613697
差值正好是 12 小时(43200 秒),同样的情况也发生在:
(new DateTime( date("Y-m-d h:i:s") ))->getTimestamp(); //acts like strtotime+date
(new DateTime("now"))->getTimestamp(); //acts like time()
为什么会这样? (因为是 12 小时,所以可能不是夏令时问题)
是 24 小时还是 12 小时模式?
【问题讨论】:
-
你为什么要这样?
-
h是 1-12。因此,如果您在早上进行测试,它会起作用:) -
@Reeno 啊谢谢!这正是我的问题 - 它有效,然后它没有 x) !
标签: php date datetime time strtotime