现在的位置: 首页 > 综合 > 正文

strtotime支持的有效时间戳

2019年10月30日 ⁄ 综合 ⁄ 共 588字 ⁄ 字号 评论关闭

今天发现一个有趣的现象
***********test.php*************************
<?php
$a = date("Y-m-d H:i:s", strtotime("2038-09-01"));
echo $a;
--------------------------------------------
:!php test.php
1970-01-01 07:00:00

查了下手册中关于strtotime的描述,注意到这段话

    Note:

    有效的时间戳通常从 Fri, 13 Dec 1901 20:45:54 GMT 到 Tue, 19 Jan 2038 03:14:07 GMT(对应于 32 位有符号整数的最小值和最大值)。不是所有的平台都支持负的时间戳,那么日记范围就被限制为不能早于 Unix 纪元。这意味着在 1970 年 1 月 1 日之前的日期将不能用在 Windows,一些 Linux 版本,以及几个其它的操作系统中。不过
PHP 5.1.0 及更新的版本克服了此限制。

    而对于64位的系统有效的时间戳则几乎是无穷的。(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.)

soga!

抱歉!评论已关闭.