DateTimeZone::listIdentifiers

timezone_identifiers_list

(PHP 5 >= 5.2.0, PHP 7, PHP 8)

DateTimeZone::listIdentifiers -- timezone_identifiers_list返回一個(gè)包含了所有時(shí)區(qū)標(biāo)示符的索引數(shù)組。

說明

面向?qū)ο箫L(fēng)格

public static DateTimeZone::listIdentifiers(int $what = DateTimeZone::ALL, string $country = null): array

過程化風(fēng)格

timezone_identifiers_list(int $what = DateTimeZone::ALL, string $country = null): array

參數(shù)

what

DateTimeZone 類中的常量之一。

country

由兩個(gè)字母組成,ISO 3166-1 兼容的國家代碼。

注意: 只有當(dāng) what 被設(shè)置為DateTimeZone::PER_COUNTRY時(shí),該選項(xiàng)才會(huì)被使用。

返回值

成功,返回?cái)?shù)組,失敗則返回false.

更新日志

版本 說明
5.3.0 添加可選的 whatcountry 參數(shù)。

范例

示例 #1 timezone_identifiers_list() 函數(shù)的范例:

<?php
$timezone_identifiers 
DateTimeZone::listIdentifiers();
for (
$i=0$i 5$i++) {
    echo 
"$timezone_identifiers[$i]\n";
}
?>

以上例程的輸出類似于:

Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara

參見