From:             jdwhale at telkomsa dot net
Operating system: Windows XP Pro
PHP version:      4.4.4
PHP Bug Type:     Date/time related
Bug description:  Incorrect GMT timestamp/offset

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 bug report at http://bugs.php.net/?id=39649&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=39649&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=39649&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=39649&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=39649&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=39649&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=39649&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=39649&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=39649&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=39649&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=39649&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=39649&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=39649&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=39649&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=39649&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=39649&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=39649&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=39649&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=39649&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=39649&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=39649&r=mysqlcfg

Reply via email to