strtotime 对于遥远未来的日期的奇怪行为
在排除一个奇怪的错误后,我遇到了这个:
echo strtotime("2050/09/19");
returns false
为什么?
谢谢!
After troubleshooting a strange error, I encountered this:
echo strtotime("2050/09/19");
returns false
Why?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
看来您没有 64 位 PHP。来自 strtotime 文档:
Looks like you don't have a 64 bit PHP. From the strtotime docs:
这是因为 2050 年并不处于 32 位 Unix 时代(该时代结束于 2038 年)。有关更多信息,请参阅strtotime() 的文档页面。
This is because of the fact year 2050 is not in the 32-bit Unix epoch (which ends somewhere in 2038). See more on the documentation page for strtotime().
在 32 位系统上,它无法处理那么远的未来日期: strtotime
On a 32-bit system it can't handle dates that far in the future: strtotime
时间戳的有效范围通常为 从 1901 年 12 月 13 日星期五 20:45:54 UTC 到 2038 年 1 月 19 日星期二 03:14:07 UTC。 (这些日期对应于 32 位有符号整数的最小值和最大值。)此外,并非所有平台都支持负时间戳,因此您的日期范围可能会被限制为不早于 Unix 纪元。这意味着 1970 年 1 月 1 日之前的日期将无法在 Windows、某些 Linux 发行版和其他一些操作系统上运行。 PHP 5.1.0 和更新版本克服了这个限制。
对于 64 位版本的 PHP,时间戳的有效范围实际上是无限的,因为 64 位可以代表任一方向大约 2930 亿年。
这里。
The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 UTC to Tue, 19 Jan 2038 03:14:07 UTC. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer.) Additionally, not all platforms support negative timestamps, therefore your date range may be limited to no earlier than the Unix epoch. This means that e.g. dates prior to Jan 1, 1970 will not work on Windows, some Linux distributions, and a few other operating systems. PHP 5.1.0 and newer versions overcome this limitation though.
For 64-bit versions of PHP, the valid range of a timestamp is effectively infinite, as 64 bits can represent approximately 293 billion years in either direction.
Here.