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).
php displays wrong date in php for 31-12-9999
Pergunta
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?
Solução
Outras dicas
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.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow