|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67129 DateTimeZone incorrect offset for MDT
Submitted: 2014-04-24 18:28 UTC Modified: 2021-01-08 10:59 UTC
From: rmeyenburg at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: *General Issues
PHP Version: 5.5.11 OS: Win7x64 (32bit PHP)
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: rmeyenburg at gmail dot com
New email:
PHP Version: OS:


 [2014-04-24 18:28 UTC] rmeyenburg at gmail dot com
From manual page:

MDT (Mountain Daylight Time) is defined as UTC-6, while the PHP DateTimeZone object reports the offset as UTC-7 (same as MST/Mountain Standard Time).

Two tests are performed to check that day of the year (in or out of daylight saving's time) isn't effecting the result - MDT is always UTC-6 regardless of time of year (since UTC doesn't move)

Tested on PHP 5.5.11, 5.4.26, 5.3.28
NOTE: 5.5 differs from 5.4, 5.3
Untested (although perhaps implied) other Daylight time zones (PDT,CDT,EDT,ADT,NDT)

Test script:
$zone=new \DateTimeZone("MDT");

$o1=$zone->getOffset(new \DateTime("2012-01-01",$zone))/3600;
$o2=$zone->getOffset(new \DateTime("2012-08-01",$zone))/3600;
echo "2012-01-01: ".($o1==-6?"Pass":"Fail ($o1)")."\n";
echo "2012-08-01: ".($o2==-6?"Pass":"Fail ($o2)")."\n";

Expected result:
2012-01-01: Pass
2012-08-01: Pass

Actual result:
// 5.5.11-Win32-VC11-x86
2012-01-01: Fail (-7)
2012-08-01: Fail (-7)

// 5.4.26-Win32-VC9-x86
2012-01-01: Fail (-7)
2012-08-01: Pass

// 5.3.28-Win32-VC9-x86
2012-01-01: Fail (-7)
2012-08-01: Pass


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2014-06-26 14:36 UTC] sly at diglin dot com
I have also a similar error with date which are after the year 2037.
I use a timezone 'Europe/Berlin'

PHP 5.5.7 (cli) (built: Jan 28 2014 02:32:47) 
Zend Server 6
OS: OS X 10.9.3

Test Script:
$zone = new \DateTimeZone("Europe/Berlin");

$o1=$zone->getOffset(new \DateTime("2079-06-06 23:59:00",$zone))/3600;
$o2=$zone->getOffset(new \DateTime("2038-06-06 23:59:00",$zone))/3600;
$o3=$zone->getOffset(new \DateTime("2037-06-06 23:59:00",$zone))/3600;
$o4=$zone->getOffset(new \DateTime("2014-06-06 23:59:00",$zone))/3600;
echo "2079-06-06 23:59:00: ".($o1==2?"Pass":"Fail ($o1)")."\n";
echo "2038-06-06 23:59:00: ".($o2==2?"Pass":"Fail ($o2)")."\n";
echo "2037-06-06 23:59:00: ".($o3==2?"Pass":"Fail ($o3)")."\n";
echo "2014-06-06 23:59:00: ".($o4==2?"Pass":"Fail ($o4)")."\n";

Expected result:
2079-06-06 23:59:00: Pass
2038-06-06 23:59:00: Pass
2037-06-06 23:59:00: Pass
2014-06-06 23:59:00: Pass

Actual Result:

2079-06-06 23:59:00: Fail (1)
2038-06-06 23:59:00: Fail (1)
2037-06-06 23:59:00: Pass
2014-06-06 23:59:00: Pass
 [2014-09-19 14:08 UTC] martin dot keckeis1 at gmail dot com
I think the problem is related to here:

Since PHP is still build for x86...

Can you try the x64 build?
 [2019-08-17 20:55 UTC] 2 dot josh dot schmidt at gmail dot com
MDT still has a -7 offset when it should be -6. It's correct in versions of php before 5.5.10 and all versions of HHVM.
 [2021-01-08 10:59 UTC]
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2021-01-08 10:59 UTC]
From the PHP manual[1]:

| Please do not use any of the timezones listed here (besides
| UTC), they only exist for backward compatible reasons, and may
| expose erroneous behavior.

Instead use a proper timezone name instead, e.g.

[1] <>
[2] <>
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Aug 15 00:05:45 2022 UTC