note 47934 added to function.strtotime
| From: | Dot_Whut? at osu1 dot php dot net | Date: | Mon, 06 Dec 2004 10:47:06 +0000 |
| Subject: | note 47934 added to function.strtotime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-81436@lists.php.net to get a copy of this message | ||
I'm not so sure the following claim (taken from above) is true in all cases:
$date_time2 = strtotime("2004-04-04 02:00:00 GMT"); // works great!
When I try this (on a server that acknowledges Pacific Daylight Savings Time):
echo date('Y-m-d H:i:s'. $date_time2);
I get:
2004-04-03 17:00:00
which is incorrect. It should be 18:00 hours, the day prior. It would appear that although GMT (or
UTC or even Z) is specified in the time string, the date is treated as if a Daylight Savings Time
switch should apply when it shouldn't.
Try this (only if your server would acknowledge PST/PDT in North America)...
// In Greenwich (UTC) at 2:00 AM on the first Sunday in April,
// it is NOT Daylight Savings Time ANYWHERE in North America
$std_time = strtotime('2004-04-04 01:59:59 UTC');
$std_time = strtotime('2004-04-04 02:00:00 UTC');
echo 'Standard Time: ' . date('Y-m-d H:i:s', $std_time) . '<br
/>';
echo 'Daylight Savings: ' . date('Y-m-d H:i:s', $dst_time) . '<br
/>';
Emits:
Standard Time: 2004-04-03 17:59:59
Daylight Savings: 2004-04-03 17:00:00
Which is totally incorrect. Why does should the clock "fall" backward anyways? I thought
the rule was "spring" forward.
The following example does work properly as expected:
// In Greenwich (UTC) at 10:00 AM on the first Sunday in April,
// it is Daylight Savings Time in most of North America
// For Mountain 08:59, Central 07:59, Eastern 06:59, Atlantic 05:59
$std_time = strtotime('2004-04-04 09:59:59 UTC');
// For Mountain 9:00, Central 08:00, Eastern 07:00, Atlantic 06:00
$dst_time = strtotime('2004-04-04 10:00:00 UTC');
echo 'Standard Time: ' . date('Y-m-d H:i:s', $std_time) . '<br
/>';
echo 'Daylight Savings: ' . date('Y-m-d H:i:s', $dst_time) . '<br
/>';
Which emits:
Standard Time: 2004-04-04 01:59:59
Daylight Savings: 2004-04-04 03:00:00
Which is correct...
----
Manual Page -- http://www.php.net/manual/en/function.strtotime.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+47934
Delete -- http://master.php.net/manage/user-notes.php?action=delete+47934&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+47934&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+47934&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+47934&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+47934&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+47934&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+47934&report=yes
Search -- http://master.php.net/manage/user-notes.php