strtotime 对于遥远未来的日期的奇怪行为

发布于 2024-12-13 13:34:36 字数 130 浏览 1 评论 0原文

在排除一个奇怪的错误后,我遇到了这个:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

七颜 2024-12-20 13:34:37

看来您没有 64 位 PHP。来自 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 亿年。

Looks like you don't have a 64 bit PHP. From the strtotime docs:

Note:

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.

热风软妹 2024-12-20 13:34:37

这是因为 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().

落花随流水 2024-12-20 13:34:37

在 32 位系统上,它无法处理那么远的未来日期: strtotime

On a 32-bit system it can't handle dates that far in the future: strtotime

孤者何惧 2024-12-20 13:34:37

时间戳的有效范围通常为 从 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文