Bug #66903 [Nab]: strtotime - diff time zones

From: Date: Fri, 14 Mar 2014 08:57:13 +0000
Subject: Bug #66903 [Nab]: strtotime - diff time zones
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184790@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66903&edit=1 ID: 66903 User updated by: a dot dyudyun at gmail dot com Reported by: a dot dyudyun at gmail dot com Summary: strtotime - diff time zones Status: Not a bug Type: Bug Package: Date/time related Operating System: Debian PHP Version: 5.4.26 Block user comment: N Private report: N New Comment: <?php date_default_timezone_set("Europe/Kiev"); echo "Kiev: ".strtotime("now") . " " . strtotime("now UTC"); echo "<br><br>"; date_default_timezone_set("America/New_York"); echo "New-York: ".strtotime("now") . " " . strtotime("now UTC"); echo "<br><br>"; date_default_timezone_set("UTC"); echo "UTC: ".strtotime("now") . " " . strtotime("now UTC"); echo "<br>==========================<br>"; date_default_timezone_set("Europe/Kiev"); echo "Kiev: ".strtotime("midnight") . " " . strtotime("midnight UTC"); echo "<br><br>"; date_default_timezone_set("America/New_York"); echo "New-York: ".strtotime("midnight") . " " . strtotime("midnight UTC"); echo "<br><br>"; date_default_timezone_set("UTC"); echo "UTC: ". strtotime("midnight") . " " . strtotime("midnight UTC"); echo "<br><br>"; ?> Result: Kiev: 1394787250 1394794450 New-York: 1394787250 1394772850 UTC: 1394787250 1394787250 ========================== Kiev: 1394748000 1394755200 New-York: 1394769600 1394755200 UTC: 1394755200 1394755200 ====================== Comments: Why "now" and "now UTC" has different values? its a bug! Previous Comments: ------------------------------------------------------------------------ [2014-03-14 08:50:31] a dot dyudyun at gmail dot com How i can know when i write some word-params to strtotime() whet it will be UTC and whet it use local time. For example strtotime("next month -1 day")? ------------------------------------------------------------------------ [2014-03-14 08:44:01] a dot dyudyun at gmail dot com So strtotime it's function that work with local time zones or with UTC? or with both? It's problem for me because strtotime("now") and strtotime("now GMT") it's have some diff ------------------------------------------------------------------------ [2014-03-14 07:45:58] requinix@php.net I take that to mean the Expected and Actual results in the report were backwards? Not a bug. "Now" is the same everywhere in the world, thus the same timestamp, but "midnight" most certainly is not. ------------------------------------------------------------------------ [2014-03-14 07:34:48] a dot dyudyun at gmail dot com About results !!! ================= Actual result: ---------------- Kiev:1394781415 New-York:1394781415 UTC:1394781415 ========================== Kiev:1394748000 New-York:1394769600 UTC:1394755200 Expected result: -------------- Kiev:1394781415 New-York:1394781415 UTC:1394781415 ========================== Kiev:1394755200 New-York:1394755200 UTC:1394755200 ------------------------------------------------------------------------ [2014-03-14 07:31:38] a dot dyudyun at gmail dot com Description: ------------ # strtotime() function with param "now" work only with UTC # time zone (GMT) Grinvich, but param "midnight" work with # local time zone Test script: --------------- <?php date_default_timezone_set("Europe/Kiev"); echo "Kiev:".strtotime("now"); echo "<br><br>"; date_default_timezone_set("America/New_York"); echo "New-York:".strtotime("now"); echo "<br><br>"; date_default_timezone_set("UTC"); echo "UTC:".strtotime("now"); echo "<br>==========================<br>"; date_default_timezone_set("Europe/Kiev"); echo "Kiev:".strtotime("midnight"); echo "<br><br>"; date_default_timezone_set("America/New_York"); echo "New-York:".strtotime("midnight"); echo "<br><br>"; date_default_timezone_set("UTC"); echo "UTC:".strtotime("midnight"); echo "<br><br>"; ?> Expected result: ---------------- Kiev:1394781415 New-York:1394781415 UTC:1394781415 ========================== Kiev:1394748000 New-York:1394769600 UTC:1394755200 Actual result: -------------- result: Kiev:1394781415 New-York:1394781415 UTC:1394781415 ========================== Kiev:1394755200 New-York:1394755200 UTC:1394755200 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=66903&edit=1

« previous php.bugs (#184790) next »