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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 02:01:33 2024 UTC