ID: 46211 Updated by: [EMAIL PROTECTED] Reported By: cmt042 at motorola dot com -Status: Open +Status: Bogus Bug Type: Date/time related Operating System: UNIX PHP Version: 5.2.6 New Comment:
We are happy to tell you that you just discovered Daylight Savings Time. For more information see: http://webexhibits.org/daylightsaving/b.html Instead of using mktime/date consider using gmmktime and gmdate which do not suffer from DST. Previous Comments: ------------------------------------------------------------------------ [2008-10-01 15:19:04] cmt042 at motorola dot com Description: ------------ When DST changes, the strtotime function give back wrong result. Reproduce code: --------------- // Need to adjust the day or hour numbers when run the code to make it cross the DST, Mar 8th 2:00AM 2009 $output = array(); for ($i = 15; $i <=19; $i++) { $t = strtotime("+157 days +${i} hours"); $output[] = date("r",$t); } foreach ($output as $line) print $line . "\n"; Expected result: ---------------- Sun, 08 Mar 2009 00:54:09 -0600 Sun, 08 Mar 2009 01:54:09 -0600 Sun, 08 Mar 2009 03:54:09 -0500 Sun, 08 Mar 2009 04:54:09 -0500 Sun, 08 Mar 2009 05:54:09 -0500 Actual result: -------------- Sun, 08 Mar 2009 00:54:09 -0600 Sun, 08 Mar 2009 01:54:09 -0600 Sun, 08 Mar 2009 03:54:09 -0500 Sun, 08 Mar 2009 03:54:09 -0500 Sun, 08 Mar 2009 04:54:09 -0500 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=46211&edit=1