ID:               39649
 Updated by:       [EMAIL PROTECTED]
 Reported By:      jdwhale at telkomsa dot net
-Status:           Open
+Status:           Feedback
 Bug Type:         Date/time related
 Operating System: Windows XP Pro
 PHP Version:      4.4.4
 New Comment:

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




Previous Comments:
------------------------------------------------------------------------

[2006-11-27 18:34:17] 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


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=39649&edit=1

Reply via email to