php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32640 Bug in either date of gmmktime
Submitted: 2005-04-09 02:16 UTC Modified: 2005-04-09 02:43 UTC
From: chris at deskpro dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.3.9 OS: Linux / Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: chris at deskpro dot com
New email:
PHP Version: OS:

 

 [2005-04-09 02:16 UTC] chris at deskpro dot com
Description:
------------
Please run the reproduce code:

In PHP 4.3.9 (windows) and PHP 4.3.7 (linux) I get the same result. 3 results are displayed in local time, 2 are in GMT and 1 (the bottom one) is meaningless.

It appears that PHP is taking the hours off, not adding them in. I do not know if this is a bug in date or gmmktime.

Importantly, this does NOT happen in PHP 5, this is what convinced me this is a bug.

Reproduce code:
---------------
echo "<table>";
echo "<tr><td>gmdate('D, jS M Y g:i a') : </td><td>" . gmdate('D, jS M Y g:i a') . "</td></tr>";
echo "<tr><td>date('D, jS M Y g:i a'); : </td><td>" . date('D, jS M Y g:i a') . "</td></tr>";
echo "<tr><td>gmdate('D, jS M Y g:i a', mktime()); : </td><td>" . gmdate('D, jS M Y g:i a', mktime()) . "</td></tr>";
echo "<tr><td>gmdate('D, jS M Y g:i a', gmmktime()); : </td><td>" . gmdate('D, jS M Y g:i a', gmmktime()) . "</td></tr>";
echo "<tr><td>date('D, jS M Y g:i a', mktime()); : </td><td>" . date('D, jS M Y g:i a', mktime()) . "</td></tr>";
echo "<tr><td>date('D, jS M Y g:i a', gmmktime()); : </td><td>" . date('D, jS M Y g:i a', gmmktime()) . "</td></tr>";
echo "</table>";

Expected result:
----------------
The results should be:

GMT
Local
GMT
Local
Local
GMT

Actual result:
--------------
GMT
Local
GMT
Local
Local
Meaningless

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-04-09 02:33 UTC] chris at deskpro dot com
I will add I get different wrong resuls (but always wrong) based on the DST setting.

This is only tested on Windows. I am in -8 GMT (PST)

with no dayling savings time (-8 PST) the last result is

NOW - 8 hours (instead of NOW + 8 hours)

When I enable DST (now in PDT) I get

GMT - 2 hours OR NOW + 6 hours

In the 1st one, the difference (8 hours) has been taken away instead of added; this is probably someone just using a - instead of a +

The problem when DST is enabled I have much less of an idea about.
 [2005-04-09 02:35 UTC] sniper@php.net
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

Try search bugs once before reporting this issue for the 100th time..

 [2005-04-09 02:43 UTC] chris at deskpro dot com
I have been checking the bugs and the only ones I can find are about documentation errors, a direct DST issue (when gmmktime is wrong by a single hour) etc.

I can't find a bug that suggests the function is completly broken, which this bug seems to suggest.

I also can't find a bug report that suggests the feature works PERFECTLY in PHP 5 but not in PHP 4. Is there a reason why the working code in PHP 5 can not be put into PHP 4.

I also still don't know which function is actually buggy. Is it date() or gmmktime(); ?

Given that echo (mktime() - gmmktime()) / (60 * 60); it seems gmmktime() is working, the difference shown is corect; so is it date() that is broken? but there certainly seems to be no date() functions.

Perhaps you can recommend the manual is updated to show which function is currently unusable?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 19:01:29 2024 UTC