1

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?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
  • possible duplicate of [PHP strtotime returning false for UTC time](http://stackoverflow.com/questions/19547043/php-strtotime-returning-false-for-utc-time) – Glavić Mar 30 '14 at 07:33

2 Answers2

2

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).

0

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.

Morgan Estes
  • 223
  • 3
  • 16