Invalid Australian DST abbreviation when using date_default_timezone_set

I am trying to represent UTC timestamp in different timezones using PHP function date_default_timezone_set. Daylight saving time has just started here (NZ) and in Australia and I am getting mixed results ...

Here is some test code ...

date_default_timezone_set('NZ');
print '<p>NZ time is ' . date('Y-m-d H:i:s T (I)') . '</p>';

date_default_timezone_set('Australia/NSW');
print '<p>NSW time is ' . date('Y-m-d H:i:s T (I)') . '</p>';

date_default_timezone_set('Australia/North');
print '<p>NT time is ' . date('Y-m-d H:i:s T (I)') . '</p>';

date_default_timezone_set('Australia/South');
print '<p>SA time is ' . date('Y-m-d H:i:s T (I)') . '</p>';

      

From where I am getting this output ...

NZ time is 2014-10-05 14:04:27 NZDT (1)

NSW time is 2014-10-05 12:04:27 EST (1)

NT time is 2014-10-05 10:34:27 CST (0)

SA time is 2014-10-05 11:34:27 CST (1)

      

Now the NZ time zone abbreviation is correct (NZDT) and all Australian times are correct, but the two Australian times in which daylight saving time is active (as indicated by the "I" date format character, which returns a '1' character if the day's savings are in place) still show an acronym other than DST.

Any ideas?

+3


source to share


1 answer


A few things:



  • You should choose the canonical form of the time zone name whenever possible. The zones you mentioned are actually links (aka aliases). See this graph for details . In particular:

    NZ              => Pacific/Auckland
    Australia/NSW   => Australia/Sydney
    Australia/North => Australia/Darwin
    Australia/South => Australia/Adelaide
    
          

  • There are actually 5 main regions in Australia with different time zone rules. You can refer to this Wikipedia article for details.

  • Australia/Darwin

    (aka, Australia/North

    ) doesn't account for daylight saving time at all.

  • The other two time zones (Sydney and Adelaide) will actually be in Daylight Saving Time on the date and time you specified. However, the names and abbreviations for Australia's time zones were not necessarily completely clear. For example, the name of Sydney Daylight was mentioned as follows:

    • Eastern Summer Time (EST)
    • Australian Summer Time (AEST)
    • Eastern Daylight Time (EDT)
    • Australian Eastern Daylight (AEDT)

  • PHP pulls its timezones from the IANA timezone database . The time zone abbreviations also come from a single source. For a very long time, this dataset has used the ambiguous abbreviation "EST" for both Eastern Standard Time and Eastern Daylight Time.

  • This was recently changed in version 2014f . You can read the details in the release notes . It now uses AEST for standard time and AEDT for daytime.

  • You can get this change by updating PHP timezonedb to 2014.6 or higher. Update instructions are here or here .

  • Alternatively, you can simply update to the latest PHP version . Based on the release dates, I think PHP version 5.3.29 should have been shipped since timezonedb 2014.6. Use this version or newer and you should get new abbreviations.

  • You can also call timezone_version_get()

    to see what version of timezonedb you have. Must be 2014.6 or greater to receive new cuts.

+5


source







All Articles