When I try to execute following statement in PHP

echo gmdate("M d Y H:i:s", gmmktime(0, 0, 0,12, 31, 9999));

PHP returns following date

Result Jan 01 1970 00:00:00

I also did try using following strtotime function but the result is same

echo gmdate("M d Y H:i:s", strtotime('2999-12-31'));

Result: Jan 01 1970 00:00:00

Any idea what could be wrong here?

有帮助吗?

解决方案

The years 9999 and 2999 are out of range for UNIX timestamps (the format returned by strtotime() and gmmktime()). The maximum valid value is INT_MAX, 0x7fffffff (around January 18th, 2038).

其他提示

The max date the gmdate function can use is 19 Jan. 2038; trying to use a date beyond that just doesn't compute (literally), so PHP returns the base Unix date that you're seeing in your result.

See http://us2.php.net/manual/en/function.gmdate.php.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top