Chirantha Posted March 9, 2006 Share Posted March 9, 2006 Hi,I noticed that I cannot seem to use the strtotime() functions with days before 1970 :(. I know how to make a function to do it but its kida slow with all the 'for' loops. So is there an easy way to do it other than making one without the use of my scipt.Thank you,Chirantha Quote Link to comment https://forums.phpfreaks.com/topic/4549-strtotime-function-problem/ Share on other sites More sharing options...
obsidian Posted March 9, 2006 Share Posted March 9, 2006 [!--quoteo(post=353350:date=Mar 9 2006, 02:29 PM:name=Chirantha)--][div class=\'quotetop\']QUOTE(Chirantha @ Mar 9 2006, 02:29 PM) [snapback]353350[/snapback][/div][div class=\'quotemain\'][!--quotec--]Hi,I noticed that I cannot seem to use the strtotime() functions with days before 1970 :(. I know how to make a function to do it but its kida slow with all the 'for' loops. So is there an easy way to do it other than making one without the use of my scipt.Thank you,Chirantha[/quote]the issue is that the built in time and date functions in PHP are based off the UNIX EPOCH (the UNIX timestamp is the number of seconds since this time) which occurred at 12am on Jan 1st, 1970. therefore, the time and date functions are not able to be used on dates before then. if you'll post what you currently have available, we may be able to help you optimize your code. Quote Link to comment https://forums.phpfreaks.com/topic/4549-strtotime-function-problem/#findComment-15889 Share on other sites More sharing options...
k.soule Posted March 10, 2006 Share Posted March 10, 2006 Interestingly enough, strtotime doesn't break when it goes farther back than eve of 1970, it just goes negative. The timestamp of March 09, 1941 is -909338400, if I plug this into date like so:print date('d-M-y', '-909338400');it prints out " 09-Mar-41 ". What exactly is breaking that you have trouble with? Quote Link to comment https://forums.phpfreaks.com/topic/4549-strtotime-function-problem/#findComment-16001 Share on other sites More sharing options...
Chirantha Posted March 10, 2006 Author Share Posted March 10, 2006 Funny Though, When I try strtotime("10 September 1900") returns -1 in php 5 :o. Quote Link to comment https://forums.phpfreaks.com/topic/4549-strtotime-function-problem/#findComment-16058 Share on other sites More sharing options...
k.soule Posted March 10, 2006 Share Posted March 10, 2006 Try strtotime("1900-09-10"), I'm on PHP 5, also. Quote Link to comment https://forums.phpfreaks.com/topic/4549-strtotime-function-problem/#findComment-16112 Share on other sites More sharing options...
obsidian Posted March 10, 2006 Share Posted March 10, 2006 [!--quoteo(post=353603:date=Mar 10 2006, 08:06 AM:name=Kyle Soule)--][div class=\'quotetop\']QUOTE(Kyle Soule @ Mar 10 2006, 08:06 AM) [snapback]353603[/snapback][/div][div class=\'quotemain\'][!--quotec--]Try strtotime("1900-09-10"), I'm on PHP 5, also.[/quote]this may help answer the problem:[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]The valid range of a timestamp is typically from Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT. (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.[/quote] Quote Link to comment https://forums.phpfreaks.com/topic/4549-strtotime-function-problem/#findComment-16113 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.