#39701 [Opn->Bgs]: Strange behaviour of gmmktime

From: Date: Fri, 01 Dec 2006 19:24:17 +0000
Subject: #39701 [Opn->Bgs]: Strange behaviour of gmmktime
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-105752@lists.php.net to get a copy of this message
ID: 39701 Updated by: iliaa@php.net Reported By: mgs at au dot ru -Status: Open +Status: Bogus Bug Type: Date/time related Operating System: Linux, Win-XP PHP Version: 5.2.0 New Comment: Without any parameters mktime() and gmmktime() are equivalent to time(). Which means the returned value will always be the same no matter the timezone. To ensure that you get the desired date you need to use gmdate () function in your code, in which case you'll see the desired results. Previous Comments: ------------------------------------------------------------------------ [2006-12-01 13:34:22] mgs at au dot ru Description: ------------ In php4 this piece of code (except date_default_timezone_get) works properly (gmtime was localtime+3(Hours)) but since date/time block was rewritten (and date_default_timezone_get is born which is happen ~PHP5.1.0) mktime and gmmktime both return the same value and date_default_timezone_get returns "Europe/Moscow". What can be wrong? Reproduce code: --------------- <?php $timelocal=mktime(); $timegm=gmmktime(); echo "local=$timelocal\n"; echo "gm =$timegm\n"; echo "local=".date("d-m-Y H:i:s",$timelocal); echo "\n"; echo "gm =".date("d-m-Y H:i:s",$timegm); echo "\n"; echo date_default_timezone_get()."\n"; ?> Expected result: ---------------- local=1164979830 gm =1164990643 local=01-12-2006 16:30:30 gm =01-12-2006 19:30:30 Europe/Moscow Actual result: -------------- local=1164979830 gm =1164979830 local=01-12-2006 16:30:30 gm =01-12-2006 16:30:30 Europe/Moscow ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39701&edit=1

« previous php.bugs (#105752) next »