tqla Posted January 6, 2009 Share Posted January 6, 2009 Maybe it's my server but strtotime() is returning a funky result for dates with high years. This returns the correct format of "01-01-2010" <?php $originalDate = '2010-01-01'; $date = date("m-d-Y", strtotime($originalDate)); echo $date; // prints 01-01-2010 ?> However, this returns "12-31-1969" <?php $originalDate = '2050-01-01'; $date = date("m-d-Y", strtotime($originalDate)); echo $date; // prints 12-31-1969 ?> Can somebody shed some light on this? Thanks. Using PHP 5.2.8 Quote Link to comment Share on other sites More sharing options...
bluesoul Posted January 6, 2009 Share Posted January 6, 2009 From php.net's strtotime page. 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.) Quote Link to comment Share on other sites More sharing options...
premiso Posted January 6, 2009 Share Posted January 6, 2009 Ah 1969, a very good year... 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. From strtotime Although you are using 5.2, your system can be preventing it, if your system does not support greater than 2038 that function will not support it. Quote Link to comment Share on other sites More sharing options...
tqla Posted January 6, 2009 Author Share Posted January 6, 2009 Thanks guys. Hmmm. This is for a date form that I am creating. There's no way in heck that someone will input a year that far in advance so I will flag all entries above 2037 as invalid. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.