문제

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