#47905 [Opn->Bgs]: strtotime() Reverses Time Zone Offsets

From: Date: Mon, 06 Apr 2009 08:34:46 +0000
Subject: #47905 [Opn->Bgs]: strtotime() Reverses Time Zone Offsets
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-135561@lists.php.net to get a copy of this message
ID: 47905 Updated by: derick@php.net Reported By: casey dot php at caseyftw dot com -Status: Open +Status: Bogus Bug Type: Date/time related Operating System: Ubuntu Linux PHP Version: 5.2.9 New Comment: You're wrong. The actual result is perfectly correct. Previous Comments: ------------------------------------------------------------------------ [2009-04-06 05:07:13] casey dot php at caseyftw dot com Description: ------------ When using strtotime($timezone), where $timezone is the timezone abbreviation, it adds negative offsets and subtracts positive offsets to the time. If you add a date string, e.g. "April 10, 2009 9:20 AM MDT", the same problem occurs. Reproduce code: --------------- <?php // It is currently 9:55 pm PDT. Default time zone is PDT. echo date('g:i a', strtotime('HADT')) . " \n"; echo date('g:i a', strtotime('AKDT')) . " \n"; echo date('g:i a', strtotime('PDT')) . " \n"; // This is the only correct one. echo date('g:i a', strtotime('MDT')) . " \n"; echo date('g:i a', strtotime('CDT')) . " \n"; echo date('g:i a', strtotime('EDT')) . " \n"; ?> Expected result: ---------------- 7:55 pm 8:55 pm 9:55 pm 10:55 pm 11:55 pm 12:55 am Actual result: -------------- 11:55 pm 10:55 pm 9:55 pm 8:55 pm 7:55 pm 6:55 pm ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=47905&edit=1

« previous php.bugs (#135561) next »