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' 列在列表顶部。
示例
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>
]
- 此存储库偶尔会抓取 rails 存储库。以下是要求 Rails 使其数据文件更容易访问的票据:rails/rails#22088
- 如果有类似的精选列表在 PHP 中会更容易。以下是向他们提出的要求:https://bugs.php.net/bug.php?id=70801
