Jump to content

strtotime() function problem


Chirantha

Recommended Posts

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
Link to comment
Share on other sites

[!--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.
Link to comment
Share on other sites

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?
Link to comment
Share on other sites

[!--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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.