tqla Posted November 14, 2012 Share Posted November 14, 2012 Hello. I do not need to know how to write this another way. I just am curious as to why this happens. Why does strtotime() print the expected result when I add 25 years: <?php $thedate = date('D M Y', strtotime("+25 year")); echo $thedate; ?> But it fails to print the expected result when I add 26 years. Instead it reads "Wed Dec 1969" <?php $thedate = date('D M Y', strtotime("+26 year")); echo $thedate; ?> Is it my version of PHP? Is there a 25 year limit? Does this happen on your system? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/270705-strtotime-question/ Share on other sites More sharing options...
MDCode Posted November 14, 2012 Share Posted November 14, 2012 (edited) I'm not sure as to what your problem could be as this works on my site. Perhaps a version of php problem. Edited November 14, 2012 by SocialCloud Quote Link to comment https://forums.phpfreaks.com/topic/270705-strtotime-question/#findComment-1392483 Share on other sites More sharing options...
PFMaBiSmAd Posted November 14, 2012 Share Posted November 14, 2012 On 32bit versions of php, the maximum integer value corresponds to - Tue, 19 Jan 2038 03:14:07 UTC Quote Link to comment https://forums.phpfreaks.com/topic/270705-strtotime-question/#findComment-1392485 Share on other sites More sharing options...
requinix Posted November 14, 2012 Share Posted November 14, 2012 Y2K38 Quote Link to comment https://forums.phpfreaks.com/topic/270705-strtotime-question/#findComment-1392487 Share on other sites More sharing options...
tqla Posted November 15, 2012 Author Share Posted November 15, 2012 (edited) Thank you all. SocialCloud, I'm glad it works in your (most likely later) version of PHP. Troubling that that sytax fails in some versions. PFMaBiSmAd and requinix, thank you for the 2038 info, the 32bit limitation it is indeed concerning. Edited November 15, 2012 by tqla Quote Link to comment https://forums.phpfreaks.com/topic/270705-strtotime-question/#findComment-1392491 Share on other sites More sharing options...
PFMaBiSmAd Posted November 15, 2012 Share Posted November 15, 2012 The php datetime class/extension should not have this problem, even on 32bit systems, assuming that you don't try to convert the result to a Unix timestamp in an integer variable. Quote Link to comment https://forums.phpfreaks.com/topic/270705-strtotime-question/#findComment-1392498 Share on other sites More sharing options...
Mahngiel Posted November 15, 2012 Share Posted November 15, 2012 Y2K38 We have to survive the mayan calendar first! Quote Link to comment https://forums.phpfreaks.com/topic/270705-strtotime-question/#findComment-1392511 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.