当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。