It's kind of a silly question, but what would be the maximum INT value of a time()
and it's future date, e.g.
1st January 2999
Would time() ever get to that value? Going for a large time()
value would return this:
Thu 1st Jan 1970 1:00AM
A normal int date
1287320788 - outputs today's date: Sun 17th Oct 2010 2:06PM
But I'm only curious for the biggest int date and the last date.
The shortest way I know is to get tomorrow's date:
date("Y-n-j", PHP_INT_MAX)
on 64bit-systems gives potential dangerous value:292277026596-12-4
Remember, the Y2038 problem does not apply on 64-bit systems.
DateTime seems to use 32bit on 64bit servers, too. So you get into trouble.
I've solve it this way:
Because, the date overflows the maximum length for DateTime, date use the maximum possibel value and returns a DateTime-object like this (inspected with var_dump) :
I'm not sure if it differs with the versions of PHP. I've tested it with version 5.4.
The last 32-Bit Integer timestamp will be reached January 19, 2038. This is known as the Year 2038 problem.
PHP stores the highest integer number it can represent in the
PHP_INT_MAX
constant:If you want to work with dates beyond that, consider using the DateTime API, e.g.
On 64-bit platforms
PHP_INT_MAX
does not reflect maximum INT value for 32-bit platforms. Here's how to get it:If you're always using 64-bit platform, just use: