Is there a way in Zend Framework or default PHP to map a country (using country code) to a list of timezones? As an example I'm trying to replicate the Google functionality when searching for "time in australia right now" which displays all of the timezones and cities for that country.
Asked
Active
Viewed 5,266 times
5
-
Could this be of help? http://zendframework.com/manual/en/zend.locale.date.datesandtimes.html#zend.locale.date.normalize – chelmertz May 13 '10 at 11:47
1 Answers
10
Not sure about Zend_Date, but native PHP can do that as of PHP5.3 with
DateTimeZone::listIdentifiers
— Returns numerically index array with all timezone identifiers
Example:
print_r( DateTimeZone::listIdentifiers(DateTimeZone::PER_COUNTRY, 'US') );
outputs:
Array
(
[0] => America/Adak
[1] => America/Anchorage
[2] => America/Boise
[3] => America/Chicago
[4] => America/Denver
[5] => America/Detroit
[6] => America/Indiana/Indianapolis
[7] => America/Indiana/Knox
[8] => America/Indiana/Marengo
[9] => America/Indiana/Petersburg
[10] => America/Indiana/Tell_City
[11] => America/Indiana/Vevay
[12] => America/Indiana/Vincennes
[13] => America/Indiana/Winamac
[14] => America/Juneau
[15] => America/Kentucky/Louisville
[16] => America/Kentucky/Monticello
[17] => America/Los_Angeles
[18] => America/Menominee
[19] => America/New_York
[20] => America/Nome
[21] => America/North_Dakota/Center
[22] => America/North_Dakota/New_Salem
[23] => America/Phoenix
[24] => America/Shiprock
[25] => America/Yakutat
[26] => Pacific/Honolulu
)
Note that the country must be supplied as a two-letter ISO 3166-1 compatible country code. Apparently, this means 'us' is not the same as 'US' (at least I don't get a result then).

Gordon
- 312,688
- 75
- 539
- 559
-
-
1@Flakerim nope sorry. But why are you still on 5.2 anyway? It has reached end of life support. Update :) – Gordon May 21 '12 at 19:17
-
Yeah, you right, but we need to upgrade our IT first :). Thanks for answer. – flakerimi May 21 '12 at 20:29