php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27909 gmmktime() produces bad result
Submitted: 2004-04-07 13:03 UTC Modified: 2004-04-18 22:49 UTC
From: cryogen at mac dot com Assigned:
Status: No Feedback Package: Date/time related
PHP Version: 4.3.4 OS: Mac OSX 10.3.3
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2004-04-07 13:03 UTC] cryogen at mac dot com
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).

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-04-12 18:18 UTC] cryogen at mac dot com
Waiting to get a build from the latest CVS snapshot to 
see if this corrects the problem.  This may take a 
while, as I do not build this myself, but depend on the 
build from Marc Liyanage www.entropy.ch.
 [2004-04-12 18:30 UTC] sniper@php.net
Give the feedback when you have it, thank you.

 [2004-04-18 22:49 UTC] iliaa@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 00:01:28 2024 UTC