Make timezone dropdown list populate with available timezones on a per Country basis?

I just noticed something really nice on the Google Analytics signup page for adding a new domain. First you pick a country them you pick your timezone. Instead of showing a huge Timezone list though they populate the timezone list with only timezones that are available for the country you have selected. I think this is a great idea to make picking a timezone easiar for some users.

So I would like to do this with jQuery since most my other javascript is using jquery already. Has anyone seen any existing jquery script that can do this for me? Or possibly how I can figure out what timezones are in each country?


Can't help with jQuery but for how to figure out what timezones are in each country, you can use DateTimeZone::listIdentifiers() with DateTimeZone::PER_COUNTRY as first argument and the ISO 3166-1 compatible country code as second argument, e.g.

DateTimeZone::listIdentifiers(DateTimeZone::PER_COUNTRY, 'GB');

Note: PHP 5.3 is required.

You can construct the data you want from this table: You would simply group by the Country code column. Probably the best way to go would be to throw all this data into a database table and use some AJAX magic to handle select menu onchange events.

Need Your Help

Why is the runtime of building a heap by inserting elements worse than using heapify?

algorithm data-structures heap big-o

In the CLRS book, building a heap by top-down heapify has the complexity O(n). A heap can also be built by repeatedly calling insertion, which has the complexity nlg(n) in the worst case.

Formatting your code

php javascript html

I'm working on this project with code that is really impossible to read simply because it is formatted so bad.