note 41324 added to function.strtotime
| From: | cryogen at mac dot com | Date: | Tue, 06 Apr 2004 14:42:09 +0000 |
| Subject: | note 41324 added to function.strtotime | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-67712@lists.php.net to get a copy of this message | ||
It appears that the strtotime() function returns a value of "-1" for the hour that is
skipped during the summer daylight savings time (2:00 am on first Sunday of April). For example if
you enter the following:
<?php
$new_dt = strtotime("2004-04-04 02:00:00");
if ($new_dt == -1) echo "Could not convert date-time!";
echo date("m/d/Y H:i:s", $new_dt);
?>
will print:
-----------
Could not convert date-time
12/31/1969 15:59:59
Any time between 02:00:00 and 2:59:59, which is the hour we "spring forward", strtotime()
will produce the bad result. This is NOT true for the "fall back" on the last Sunday of
October at 2:00 am when the clocks are set back an hour, which produces a correct result. This can
cause problems if you are storing dates in GMT time, for example, in your database, and need to
convert them to a unix timestamp for calculations in your PHP scripts. GMT time does not change
during daylight savings time.
----
Manual Page -- http://www.php.net/manual/en/function.strtotime.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41324
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41324&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41324&report=yes
Search -- http://master.php.net/manage/user-notes.php