note 41324 deleted from function.strtotime by derick
| From: | derick@php.net | Date: | Sun, 15 Jul 2007 12:52:00 +0000 |
| Subject: | note 41324 deleted from function.strtotime by derick | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-128596@lists.php.net to get a copy of this message | ||
Note Submitter: cryogen at mac dot com
----
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.