php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47905 strtotime() Reverses Time Zone Offsets
Submitted: 2009-04-06 05:07 UTC Modified: 2009-04-06 08:34 UTC
From: casey dot php at caseyftw dot com Assigned:
Status: Not a bug Package: Date/time related
PHP Version: 5.2.9 OS: Ubuntu Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: casey dot php at caseyftw dot com
New email:
PHP Version: OS:

 

 [2009-04-06 05:07 UTC] 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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-06 08:34 UTC] derick@php.net
You're wrong. The actual result is perfectly correct.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Dec 01 19:00:01 2025 UTC