|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-04-24 18:28 UTC] rmeyenburg at gmail dot com
Description: ------------ --- From manual page: http://www.php.net/datetimezone.getoffset --- 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: --------------- <?php $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 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 02:00:01 2025 UTC |
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: <?php $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