php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39649 Incorrect GMT timestamp/offset
Submitted: 2006-11-27 18:34 UTC Modified: 2006-11-28 11:27 UTC
From: jdwhale at telkomsa dot net Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 4.4.4 OS: Windows XP Pro
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: jdwhale at telkomsa dot net
New email:
PHP Version: OS:

 

 [2006-11-27 18:34 UTC] jdwhale at telkomsa dot net
Description:
------------
This issue seems to be closely related to bug 36367. While the gmdate function returns correctly, the gmmktime function returns an incorrect timestamp - the "offset" from localtime to GMT being in the wrong direction.

I am running Apache 2.0.59 in South Africa (GMT +0200). If I am 2 hours later than GMT, then the GMT timestamp equivalent to my local time must surely be less by 7200 - not more.

Reproduce code:
---------------
<?php
$time1=mktime(15,0,0,1,15,2006);
$time1a=date("Y-m-d,H:i", mktime(15,0,0,1,15,2006));    
echo $time1a."<br />"; //displays 2006-01-15,15:00 (correct)
$time2=gmmktime(15,0,0,1,15,2006);
$time2a=gmdate("Y-m-d,H:i", mktime(15,0,0,1,15,2006));
echo $time2a."<br />"; //displays 2006-01-15,13:00 (correct)
$hrsdiff=($time1-$time2)/3600;
echo $hrsdiff."<br />";            //displays -2 (incorrect)
echo $time1."<br />";        //displays 1137330000 (correct)
echo $time2."<br />";        //displays 1137337200 (incorrect)
$hr1=date("H",$time1);
$hr2=date("H",$time2);
echo $hr1."<br />";          //displays 15 (correct)
echo $hr2;                   //displays 17 (incorrect)
?>


Expected result:
----------------
If localtime is 2 hours later than GMT, $time2 should be 1137322800; $hrsdiff should be +2; $hr2 should be 13

Actual result:
--------------
As shown in code comments

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-11-27 23:10 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip


 [2006-11-28 11:27 UTC] mgf@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 19:01:30 2024 UTC