php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41869 current time returned for haiti and Etc/GMT-* timezone incorrect
Submitted: 2007-07-02 07:44 UTC Modified: 2007-07-05 14:01 UTC
From: gnupun at yahoo dot com Assigned: derick (profile)
Status: Closed Package: Date/time related
PHP Version: 5.2.3 OS: windows xp
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: gnupun at yahoo dot com
New email:
PHP Version: OS:

 

 [2007-07-02 07:44 UTC] gnupun at yahoo dot com
Description:
------------
PHP returns incorrect time for the following timezones:
America/Port-au-Prince
Etc/GMT+*
Etc/GMT-*

where * is a digit 1-9.

Eg: Etc/GMT+1 returns time 1 hour before Etc/GMT
Similarly, Etc/GMT-1 returns time 1 hour after Etc/GMT


Reproduce code:
---------------
function print_current_time($timezone) {
	date_default_timezone_set($timezone);
	$s = strftime("%I:%M:%S %p %d %B %Y");
	printf("%20s: %s\n", $timezone, $s);
}

print_current_time('America/Port-au-Prince');
print_current_time('Etc/GMT');
print_current_time('Etc/GMT+1');
print_current_time('Etc/GMT-1');



Expected result:
----------------
America/Port-au-Prince: 02:36:53 AM 02 July 2007
             Etc/GMT: 07:36:53 AM 02 July 2007
           Etc/GMT+1: 08:36:53 AM 02 July 2007
           Etc/GMT-1: 06:36:53 AM 02 July 2007

Actual result:
--------------
America/Port-au-Prince: 03:36:53 AM 02 July 2007
             Etc/GMT: 07:36:53 AM 02 July 2007
           Etc/GMT+1: 06:36:53 AM 02 July 2007
           Etc/GMT-1: 08:36:53 AM 02 July 2007

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-03 06:52 UTC] tony2001@php.net
Derick, looks like the timezone DB needs an update.
 [2007-07-05 13:51 UTC] derick@php.net
I updated the timezone database (you can use it by installing the timezonedb extension from PECL). 

However the following statement is *correct* behavior:

Eg: Etc/GMT+1 returns time 1 hour before Etc/GMT
Similarly, Etc/GMT-1 returns time 1 hour after Etc/GMT

This is how the timezone database does it - however, please try to avoid using timezones like this as they do not take care of DST and the like.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 01:01:28 2024 UTC