Reputation: 4555
After troubleshooting a strange error, I encountered this:
echo strtotime("2050/09/19");
returns false
Why?
Thanks!
Upvotes: 2
Views: 1047
Reputation: 5214
The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 UTC to Tue, 19 Jan 2038 03:14:07 UTC. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer.) Additionally, not all platforms support negative timestamps, therefore your date range may be limited to no earlier than the Unix epoch. This means that e.g. dates prior to Jan 1, 1970 will not work on Windows, some Linux distributions, and a few other operating systems. PHP 5.1.0 and newer versions overcome this limitation though.
For 64-bit versions of PHP, the valid range of a timestamp is effectively infinite, as 64 bits can represent approximately 293 billion years in either direction.
Upvotes: 2
Reputation: 137440
This is because of the fact year 2050 is not in the 32-bit Unix epoch (which ends somewhere in 2038). See more on the documentation page for strtotime().
Upvotes: 3
Reputation: 206879
Looks like you don't have a 64 bit PHP. From the strtotime docs:
Note:
The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 UTC to Tue, 19 Jan 2038 03:14:07 UTC. (These are the dates that correspond to the minimum and maximum values for a 32-bit signed integer.) Additionally, not all platforms support negative timestamps, therefore your date range may be limited to no earlier than the Unix epoch. This means that e.g. dates prior to Jan 1, 1970 will not work on Windows, some Linux distributions, and a few other operating systems. PHP 5.1.0 and newer versions overcome this limitation though.
For 64-bit versions of PHP, the valid range of a timestamp is effectively infinite, as 64 bits can represent approximately 293 billion years in either direction.
Upvotes: 4
Reputation: 6126
On a 32-bit system it can't handle dates that far in the future: strtotime
Upvotes: 3