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

From: Date: Fri, 14 Mar 2014 09:08:02 +0000
Subject: Bug #66903 [Nab]: strtotime - diff time zones
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-184791@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 Updated by: requinix@php.net 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: It will use whatever timezone you provide, or the default if there wasn't one. The question is whether the timezone matters for the string you provide. "now" is now, like I said. Timezone is irrelevant. "now UTC" will be the current time in your timezone treated as if it were instead a UTC time. "next month -1 day" will be the current date and time, in the current timezone, in one day less than a month from now. There is documentation specifically dedicated to this question. http://www.php.net/manual/en/datetime.formats.php If that doesn't answer your question about a format, simply try it and see what happens. Previous Comments: ------------------------------------------------------------------------ [2014-03-14 08:57:13] a dot dyudyun at gmail dot com <?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! ------------------------------------------------------------------------ [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 ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=66903 -- Edit this bug report at https://bugs.php.net/bug.php?id=66903&edit=1

« previous php.bugs (#184791) next »