Why are there different timezones between DateTimeZone :: listAbbreviations() and DateTimeZone :: listIdentifiers ()

Viewed 183

I want to get a list of all timezones.

When I use DateTimeZone::listIdentifiers() I get a list,

And when I use DateTimeZone::listAbbreviations() I get a list with different entries.

Each list has values that are not in the second list. How to get a complete list?

Why is there a difference between the two functions?

2 Answers

Identifiers and abbreviations are different things, thus you get different lists.

An identifier is bound to a location, so a single time zone (Central Europe Time) will typically relate to several identifiers (Europe/Madrid, Europe/Paris, Europe/Berlin...) and one same identifier can switch time zones (Europe/Madrid is Central European Time, UTC+1, in Winter and Central European Summer Time, UTC+2, in Summer).

An abbreviation is bound to a time zone, so a single abbreviation (CET) only maps to one time zone (Central Europe Time, UTC+1).

If you inspect DateTimeZone::listAbbreviations())'s output you'll see that each time zone abbreviation contains a list of its known location identifiers, and they aren't unique because many of them switch time zones due to daylight saving time or political changes.

Are you use the function "timezone_identifiers_list()"? Return parameter is array, exp: $timezone_list = timezone_identifiers_list(); print_r($timezone);

Related