MontyMoose Posted January 6, 2011 Share Posted January 6, 2011 Hello wize PHP dudes. I'm a fairly advanced PHP user, but I'm confused by STRTOTIME producing different results on two identical servers. Both running PHP Version 5.2.6-3. - Server 1: echo date("Y",strtotime('1763-03-24 00:00:00')); returns '1763' - Server 2: echo date("Y",strtotime('1763-03-24 00:00:00')); returns '1970' Why do you reckon Server 1 seems not to worry about the Unix Epoch date limit, and happily computes the 1763 date? I would really like Server 2 to do the same thing, but having gone through the php.ini I can't see any difference. I would really like Server 2 to start working with older dates. I don't want a workaround, as server 1 has been working with just strtotime for years. I can't remember doing anything different on setup. Weird! Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/223566-strtotime-different-results-on-different-servers/ Share on other sites More sharing options...
MMDE Posted January 6, 2011 Share Posted January 6, 2011 On my homeserver I also got 1970... (which is winxp 32bit) OS of the two servers? EDIT: read the notes for the function here: http://php.net/manual/en/function.strtotime.php Quote Link to comment https://forums.phpfreaks.com/topic/223566-strtotime-different-results-on-different-servers/#findComment-1155651 Share on other sites More sharing options...
MontyMoose Posted January 6, 2011 Author Share Posted January 6, 2011 Found the problem but not an easy solution sadly. One of my servers is 64bit hence the longer timestamp range. The 32bit version of strtotime doesn't work for dates earlier than 1901. date_create() does work but most of my code will have to be rewritten by the sounds of things. :-( Quote Link to comment https://forums.phpfreaks.com/topic/223566-strtotime-different-results-on-different-servers/#findComment-1155669 Share on other sites More sharing options...
PFMaBiSmAd Posted January 6, 2011 Share Posted January 6, 2011 If this data happens to be in a database, it is best (fastest, simplest code, avoids php's Unix timestamp problems...) to do any date formatting in the query when you retrieve the data. Quote Link to comment https://forums.phpfreaks.com/topic/223566-strtotime-different-results-on-different-servers/#findComment-1155671 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.