(PHP 5 >= 5.2.0, PHP 7, PHP 8)
DateTimeZone::listIdentifiers -- timezone_identifiers_list — 返回一個(gè)包含了所有時(shí)區標示符的索引數組。
面向對象風(fēng)格
$what
= DateTimeZone::ALL, string $country
= null
): array過(guò)程化風(fēng)格
what
DateTimeZone 類(lèi)中的常量之一。
country
由兩個(gè)字母組成,ISO 3166-1 兼容的國家代碼。
注意: 只有當
what
被設置為DateTimeZone::PER_COUNTRY
時(shí),該選項才會(huì )被使用。
成功,返回數組,失敗則返回false
.
版本 | 說(shuō)明 |
---|---|
5.3.0 |
添加可選的 what 和
country 參數。
|
示例 #1 timezone_identifiers_list() 函數的范例:
<?php
$timezone_identifiers = DateTimeZone::listIdentifiers();
for ($i=0; $i < 5; $i++) {
echo "$timezone_identifiers[$i]\n";
}
?>
以上例程的輸出類(lèi)似于:
Africa/Abidjan Africa/Accra Africa/Addis_Ababa Africa/Algiers Africa/Asmara