Make timezone dropdown list populate with available timezones on a per Country basis?
I just noti开发者_Go百科ced 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: http://www.datelib.de/Timezones.shtml.en. 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.
精彩评论