note 41328 modified in function.strtotime by danbrown

From: Date: Mon, 18 May 2009 02:31:25 +0000
Subject: note 41328 modified in function.strtotime by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-155658@lists.php.net to get a copy of this message
Append the string "GMT" to all of your datetimes pulled from MySQL or other database that store date-times in the format "yyyy-mm-dd hh:ii:ss" just prior to converting them to a unix timestamp with strtotime(). This will ensure you get a valid GMT result for times during daylight savings. EXAMPLE: <?php $date_time1 = strtotime("2004-04-04 02:00:00"); // returns bad value -1 due to DST $date_time2 = strtotime("2004-04-04 02:00:00 GMT"); // works great! ?> --was-- I neglected to include the solution in my last post for using strtotime() with date-time data stored in GMT. Append the string "GMT" to all of your datetimes pulled from MySQL or other database that store date-times in the format "yyyy-mm-dd hh:ii:ss" just prior to converting them to a unix timestamp with strtotime(). This will ensure you get a valid GMT result for times during daylight savings. EXAMPLE: <?php $date_time1 = strtotime("2004-04-04 02:00:00"); // returns bad value -1 due to DST $date_time2 = strtotime("2004-04-04 02:00:00 GMT"); // works great! ?> http://php.net/manual/en/function.strtotime.php

« previous php.notes (#155658) next »