使时区下拉列表中填充每个国家可用的时区? [英] Make timezone dropdown list populate with available timezones on a per Country basis?

查看:166
本文介绍了使时区下拉列表中填充每个国家可用的时区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在Google Analytics(分析)注册页面上注意到了一些非常不错的功能,用于添加新域.首先,您选择一个国家/地区,然后选择您的时区.尽管它们会在时区列表中仅填充您所选国家/地区可用的时区,但不会显示巨大的时区列表.我认为这对于让某些用户选择时区更加方便是一个好主意.

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.

因此,我想使用jQuery来完成此操作,因为大多数我的其他javascript都已在使用jquery.有没有人看到任何现有的jQuery脚本可以为我做到这一点?或者可能如何找出每个国家的时区?

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?

推荐答案

无法使用jQuery,但要了解每个国家/地区的时区,可以使用

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');

注意:需要PHP 5.3.

这篇关于使时区下拉列表中填充每个国家可用的时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆