icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » PHP, MySQL » PHP timestamp for dates before 1970?

PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >>

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
Old September 4th, 2004, 8:20 PM   #1 (permalink)
crishchun.net
Fresh Surpasser
 
crishchun's Avatar
 
Joined in Oct 2003
Lives in NJ, USA
Hosted on Pass16
13 posts
Gave thanks: 0
Thanked 0 times
PHP timestamp for dates before 1970?

I thought PHP can handle negative timestamps from 1901 to 1970 and positive timestamps from 1970 to 2038? But when I execute this code:

PHP Code:
<?php
 $bday 
"31 December 1959";
 echo 
"$bday<br />";
 echo 
strtotime($bday) . "<br />";
?>
I get an error (-1) for the output.

Quote:
31 December 1959
-1
I have a 'person_birthday' field in a MySQL database table which stores dates as timestamps, so when that when I retrieve it, I can use date() to format the timestamp to my liking. But I can't store any bdays before 1970? How can I fix or work around this problem? Thanks for your replies.

By the way, I'm on a shared host Linux server.
__________________
-Christian

PASS16
www.simplifi3d.com

Last edited by crishchun; September 4th, 2004 at 8:28 PM..
crishchun is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old September 4th, 2004, 9:04 PM   #2 (permalink)
Dark Matter
Guest
 
n/a posts
My guess and most likely wrong, is that it could be the caused of the 2000/1900 bug from the 1970 where the programmers only put 2 binary digits instead of 4. The other wild guess is that that was the Time of Punch-Cards.

You might wanna send this question to the "horse's mouth" and get the better answer.
 
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old September 4th, 2004, 10:21 PM   #3 (permalink)
the one who was
Super #1
 
patrickb's Avatar
 
Joined in Jul 2003
Lives in Memphis
1,967 posts
Gave thanks: 0
Thanked 3 times
From php.net:

Quote:
Note: 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.
Sorry, it won't work. Best bet is to design a function to convert the string yourself to a value suitable for this type of thing. YYYYMMDD would be a good bet. Timestamps are more geared towards tracking entry times and the such, not tracking birthdays.
__________________
Patrick

Warnings: The program(s) might crash unexpectedly or behave otherwise strangely. (But of course, so do many commercial programs on Windows.) --www.gimp.org
patrickb is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On