當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


PHP timezone_abbreviations_list()用法及代碼示例


timezone_abbreviations_list()函數是PHP中的內置函數,用於返回包含dst,offset和時區名稱的關聯數組。不需要參數即可發送到timezone_abbreviations_list()函數,並且成功時返回關聯數組,失敗時返回False。

用法:

array timezone_abbreviations_list()

參數:timezone_abbreviations_list()函數不需要任何參數。


返回值:此函數返回一個包含dst,offset和時區名稱的關聯數組。

異常:timezone_identifiers_list()函數是DateTimeZone::listAbbreviations()函數的別名。

以下示例程序旨在說明PHP中的timezone_abbreviations_list()函數:

程序1:

<?php 
  
// Printing dst, offset, and timezone 
// name for the "acst" timezone 
$timezone_list = timezone_abbreviations_list(); 
print_r($timezone_list["acst"]); 
?>
輸出:
Array
(
    [0] => Array
        (
            [dst] => 
            [offset] => 32400
            [timezone_id] => Australia/Adelaide
        )

    [1] => Array
        (
            [dst] => 
            [offset] => 34200
            [timezone_id] => Australia/Adelaide
        )

    [2] => Array
        (
            [dst] => 
            [offset] => 32400
            [timezone_id] => Australia/Broken_Hill
        )

    [3] => Array
        (
            [dst] => 
            [offset] => 32400
            [timezone_id] => Australia/Darwin
        )

    [4] => Array
        (
            [dst] => 
            [offset] => 32400
            [timezone_id] => Australia/North
        )

    [5] => Array
        (
            [dst] => 
            [offset] => 32400
            [timezone_id] => Australia/South
        )

    [6] => Array
        (
            [dst] => 
            [offset] => 32400
            [timezone_id] => Australia/Yancowinna
        )

    [7] => Array
        (
            [dst] => 
            [offset] => 34200
            [timezone_id] => Australia/Broken_Hill
        )

    [8] => Array
        (
            [dst] => 
            [offset] => 34200
            [timezone_id] => Australia/Darwin
        )

    [9] => Array
        (
            [dst] => 
            [offset] => 34200
            [timezone_id] => Australia/North
        )

    [10] => Array
        (
            [dst] => 
            [offset] => 34200
            [timezone_id] => Australia/South
        )

    [11] => Array
        (
            [dst] => 
            [offset] => 34200
            [timezone_id] => Australia/Yancowinna
        )

)

程序2:

<?php 
  
// Printing dst, offset, and timezone name  
// for the "acst" timezone 
$timezone_abbreviations = DateTimeZone::listAbbreviations(); 
print_r($timezone_abbreviations["acst"]); 
?>
輸出:
Array
(
    [0] => Array
        (
            [dst] => 
            [offset] => 32400
            [timezone_id] => Australia/Adelaide
        )

    [1] => Array
        (
            [dst] => 
            [offset] => 34200
            [timezone_id] => Australia/Adelaide
        )

    [2] => Array
        (
            [dst] => 
            [offset] => 32400
            [timezone_id] => Australia/Broken_Hill
        )

    [3] => Array
        (
            [dst] => 
            [offset] => 32400
            [timezone_id] => Australia/Darwin
        )

    [4] => Array
        (
            [dst] => 
            [offset] => 32400
            [timezone_id] => Australia/North
        )

    [5] => Array
        (
            [dst] => 
            [offset] => 32400
            [timezone_id] => Australia/South
        )

    [6] => Array
        (
            [dst] => 
            [offset] => 32400
            [timezone_id] => Australia/Yancowinna
        )

    [7] => Array
        (
            [dst] => 
            [offset] => 34200
            [timezone_id] => Australia/Broken_Hill
        )

    [8] => Array
        (
            [dst] => 
            [offset] => 34200
            [timezone_id] => Australia/Darwin
        )

    [9] => Array
        (
            [dst] => 
            [offset] => 34200
            [timezone_id] => Australia/North
        )

    [10] => Array
        (
            [dst] => 
            [offset] => 34200
            [timezone_id] => Australia/South
        )

    [11] => Array
        (
            [dst] => 
            [offset] => 34200
            [timezone_id] => Australia/Yancowinna
        )

)

相關文章:

參考: http://php.net/manual/en/function.timezone-abbreviations-list.php



相關用法


注:本文由純淨天空篩選整理自Shubrodeep Banerjee大神的英文原創作品 PHP | timezone_abbreviations_list() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。