douyi2664 2010-05-13 11:41
浏览 33

PHP / Zend Framework中的时区的国家/地区

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.

  • 写回答

1条回答 默认 最新

  • dsrnwngq411594 2010-05-13 11:46
    关注

    Not sure about Zend_Date, but native PHP can do that as of PHP5.3 with

    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).

    评论

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100