php 带有未来日期时间的 strtotime returns 时间戳小于当前时间戳

php strtotime with a future datetime returns a timestamp less than current timestamp

我在我的服务器上 运行 php。 strtotime 函数的文档说它将尝试将日期字符串解析为 Unix 时间戳(自 1970 年 1 月 1 日 00:00:00 UTC 以来的秒数)。

所以我的测试场景是:

字符串的时间戳 "2018-05-15 14:30": 1526387400 => strtotime("2018-05-15 14:30")

GMT 当前时间戳 2018-05-15 13:26 : 1526390790 => time()

这里我希望 14:30 的时间戳大于 13:26。但是尽管有未来的日期字符串,该值仍小于当前时间戳。

我正在测试的服务器在 GMT+2 timezone = date('Z') => 7200 上运行。 我假设根据文档,strtotime 函数自纪元以来经过了 return 秒,而不考虑时区偏移量。我不确定时区偏移是否弄乱了数字。

对此的任何见解都会非常有帮助。

来自 strtotime() manual

Each parameter of this function uses the default time zone unless a time zone is specified in that parameter. Be careful not to use different time zones in each parameter unless that is intended.

来自time() manual

Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT).

所以你的 strtotime() 是 GMT+2,time() 是 GMT