Forum Moderators: coopster

Message Too Old, No Replies

Extremely weird mktime() problem

         

Ben_Johnson

3:25 am on Jan 17, 2006 (gmt 0)

10+ Year Member



This is really weird and I dont see any reason why the mktime() function would do this. Here is the php:

print '1-1-1950: '.mktime(0,0,0,1,1,1950).'<br />1-1-1960: '.mktime(0,0,0,1,1,1960).'<br />1-1-1970: '.mktime(0,0,0,1,1,1970);

Here is what it printed out:

1-1-1950: -14462
1-1-1960: -14462
1-1-1970: 21600

It seems that anything older than 1960 in the mktime function passes bak -14462 and thats it. It wont print out the proper negative timestamp.

Any reason why? Also, I'm storing this timestamp in the database for date of birth. It's crazy, but some people were born before 1969, so what should I do if I cant use the mktime function?

Thanks for your help.

Ben_Johnson

3:28 am on Jan 17, 2006 (gmt 0)

10+ Year Member



I also found this on: [us3.php.net...]

Before PHP 5.1.0, negative timestamps were not supported under any known version of Windows and some other systems as well. Therefore the range of valid years was limited to 1970 through 2038.

So how can I store a timestamp that represents a date before 1970?

Thanks for your help.

sonjay

1:30 pm on Jan 17, 2006 (gmt 0)

10+ Year Member



If you go back to php.net and scroll all the way down almost to the bottom of that page, you'll find a user comment that starts "If you want to calculate dates before 1970 and your OS doesn't support it (Windows and Linux), you can easily write your own wrapper to mktime to do the calculation." That post appears to provide the information you need to do what you want.