First off, this is not a question about how to fix a problem because my date is outputting 1969.
This is a question about why time does not exist before 1970 or after 2038 when using date()
.
I've tried seaching SO and Google but all that turns up is people getting errors when using date()
incorrectly, resulting in the familiar output of December 31, 1969 5:00 pm
Does anyone know why it can't go before 1970? Should we stop using date()
since it will be unusable after 2038? What's the history on this? What's the work around for working with dates outside of this range?
It's 2038 problem
and look, I'm in year 1653
This is explained on the PHP manual page for date()
:
The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer).
The fact that you're getting December 31, 1969 means that you're likely supplying an odd timestamp
parameter to date()
, resulting in a date that isn't what you expect. Like @Mitch Wheat said in his comment, this relates to Unix time since it is relative from January 1, 1970.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With