|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-03-14 07:31 UTC] 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
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 13:00:01 2025 UTC |
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 diffHow 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")?<?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!