note 28905 rejected from function.date by sp
| From: | sp@php.net | Date: | Sat, 21 Jun 2003 14:36:49 +0000 |
| Subject: | note 28905 rejected from function.date by sp | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-50786@lists.php.net to get a copy of this message | ||
Note Submitter: No@spam@cam@wecreate.nukethis.com
----
Beware of the evil integer overflow.
The following code will not work for dates older than December 14 1901 (and presumably some time in
2037).
$date="1901-12-13"; // and older
list($year,$month,$day) = split("-",$date);
$time =mktime(0,0,0,$month,$day,$year);
echo date("l F jS, Y",$time);
I get "Wednesday December 31st, 1969" every time.
Why? (I think) mktime() returns "-1" for dates that are before this which is the
equivalent of EPOCH-1 when passed into the date() function.
I'd assume that this problem isn't present on 64-bit hardware.
Does anyone have a work around? Preferably one that doesn't involve rewriting the date
function.