array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'datetimezone.listabbreviations.php', 1 => 'DateTimeZone::listAbbreviations', ), 'up' => array ( 0 => 'class.datetimezone.php', 1 => 'DateTimeZone', ), 'prev' => array ( 0 => 'datetimezone.gettransitions.php', 1 => 'DateTimeZone::getTransitions', ), 'next' => array ( 0 => 'datetimezone.listidentifiers.php', 1 => 'DateTimeZone::listIdentifiers', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/datetime/datetimezone/listabbreviations.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5 >= 5.2.0, PHP 7, PHP 8)
DateTimeZone::listAbbreviations -- timezone_abbreviations_list — 返回一个包含 dst (夏令时),时差和时区信息的关联数组。
面向对象风格
过程化风格
返回简写列表,包含历史上所有使用过的简写,这可能会导致既正确又混乱的条目。也会存在冲突,比如
PST
在美国和菲律宾都在有使用。
因此函数返回的列表不适合构建为带选项的数组,以便向用户提供时区选择。
注意:
出于性能考虑,会预先编译此函数的数据。在使用较新的 » timezonedb 时不会更新。
此函数没有参数。
返回时区简写数组。
示例 #1 timezone_abbreviations_list() 函数的范例:
<?php
$timezone_abbreviations = DateTimeZone::listAbbreviations();
print_r($timezone_abbreviations["acst"]);
?>
以上示例的输出类似于:
Array ( [0] => Array ( [dst] => 1 [offset] => -14400 [timezone_id] => America/Porto_Acre ) [1] => Array ( [dst] => 1 [offset] => -14400 [timezone_id] => America/Eirunepe ) [2] => Array ( [dst] => 1 [offset] => -14400 [timezone_id] => America/Rio_Branco ) [3] => Array ( [dst] => 1 [offset] => -14400 [timezone_id] => Brazil/Acre ) )