scottconnerly/timezone

将 Ruby on Rails 的时区列表引入 PHP。

v0.2 2018-03-27 14:42 UTC

This package is not auto-updated.

Last update: 2024-09-28 18:26:38 UTC


README

在 PHP 中创建时区选择可能很快就会变得混乱,因为 DateTimeZone::listIdentifiers() 返回超过 415 个区域和链接。这是尝试借鉴 Ruby on Rails 的 ActiveSupport::TimeZone time_zone_select() 的一个页面,主要通过使用他们的约 150 个区域的精选列表,同时也允许 'priority_zones' 列在列表顶部。

Screenshot of timezone select

示例

echo TimeZoneSelect::get_select(['country'=>'US']);

简单示例可用: http://scott.connerly.net/TimeZone/example.php

可用参数及默认值

[
    'country'        => '',          //ISO-3116 2-letter country code
    'priority_zones' => [],          //If you want to specify a list of zones that aren't country-specific
    'priority_label' => 'Regional',  //The label of the optgroup for the priority zones

    'selected'       => '',          //which option is selected
    
    'name'           => 'time_zone', //name for the <select>
    'class'          => '',          //class for the <select>
    'id'             => '',          //id for the <select>
    'data'           => [],          //list of data attributes to add to the <select>
]