From:             cryogen at mac dot com
Operating system: Mac OSX 10.3.3
PHP version:      4.3.4
PHP Bug Type:     Date/time related
Bug description:  gmmktime() produces bad result

Description:
------------
MacOSX 10.3.3 - PHP 4.3.4 (entropy.ch), California PST



I searched through the existing bug submissions, but did 

not find anyone reporting this specific problem on Mac 

OSX, so 

here it is.  I am using dates stored as GMT dates in 

order to 

provide my users across the world with accurate date-

times in their local time zones (using timezone offsets 

to GMT).  

During the changover to daylight savings time on April 

4, 2004 I ran into what I think is a bug with 

gmmktime().  Here is the code snippet:

Reproduce code:
---------------
<?php

$td = gmmktime(2,0,0,4,4,2004);

echo "<p>April 4, 2004 - 02:00 am<br/>";

echo "GMDATE = ".gmdate("m/d/Y H:i:s (g:i a)",$td)."<br/>";

echo "DATE = ".date("m/d/Y H:i:s (g:i a)",$td)."<br/>";

?>

Expected result:
----------------
What I expected to see for the GMDATE result was the 

same date I input in gmmktime() - "04/04/2004 02:00:00 

(02:00 am)".

Actual result:
--------------
What I am actually getting is: "GMDATE = 12/31/1969 16:

58:58 (4:58 pm)", or an invalid result.



Since gmmktime() is supposed to take GMT date input 

parameters as per the documentation, 2:00 am on April 

4th is valid, since GMT 

does not have daylight savings time and should not have 

any code to deal with DST.  It seems like it is behaving 

the same as mktime() which does not deal with the one 

hour we "spring forward" during daylight savings time 

(that hour essentially does not exist).



NOTE#1: I tested this on Windows XP with PHP 4.3.4, 

Pacific time zone and got 

the result "04/04/2004 01:00:00 (01:00 am)" which is 

better, but still wrong. since gmmktime should not 

adjust the time at all for GMT, especially not in the 

wrong direction!.



NOTE #2: I also tested this on Solaris with PHP 4.3.4, 

Pacific time zone and got the same result as Windows of 

04/04/2004 01:00:00 (01:00 am).



NOTE #3: I also tested this on Redhat 9.0, PHP 4.3.6 in 

Central Standard Time and got a result of 04/04/2004 03:

00:00 (03:00 am)?  This one seems to be adjusting for 

DST (although it should be 4:00am) even though it should 

not.



NOTE #4: I also tested this on a Redhat Linux Machine 

(v.9.0 PHP 4.3.4 Mountain Standard Time) and got the 

correct result of "04/04/2004 02:00:00 (02:00am)", 

although I fear this is because of the time being set to 

01:00am and then adjusted to 2:00am for DST Mountain 

time (again, wrong).

-- 
Edit bug report at http://bugs.php.net/?id=27909&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=27909&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=27909&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=27909&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=27909&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=27909&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=27909&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=27909&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=27909&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=27909&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=27909&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=27909&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=27909&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27909&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=27909&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=27909&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=27909&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27909&r=float

Reply via email to