NYCPHP Meetup

NYPHP.org

[nycphp-talk] Date Calculation Error

drydell at att.net drydell at att.net
Thu May 27 20:00:32 EDT 2004


I had a date calculation bug that was driving me nuts all day, and I finally figured it out... on two different servers (one UNIX, one Windows; both PHP 4.3), midnight 10/31/2004 and midnight 11/01/2004 are 25 hours apart. Does anyone else get the same result? Here's a snippet to try:

<?
$ts1 = mktime(0, 0, 0, 10, 31, 2004);
$ts2 = mktime(0, 0, 0, 11, 1, 2004);
$diff = ($ts2 - $ts1) / (60 * 60);
print "ts1 = $ts1<br>ts2 = $ts2<br>difference is $diff hours";
?>

Here's my output (both servers):

ts1 = 1099195200
ts2 = 1099285200
difference is 25 hours

All other consecutive dates I tried give a 24 hour difference, as does 10/31 - 11/1 in 2003 and 2005... is this a PHP bug? could it possibly have anything to do with daylight savings time?



More information about the talk mailing list