PHP - Function timezone_abbreviations_list()


Advertisements


Syntax

array timezone_abbreviations_list ( void );

array DateTimeZone::listAbbreviations ( void );

Definition and Usage

These functions return associative array containing dst, offset and the timezone name.

The above two functions are equivalent and any of the functions can be used as shown below in the example.

Parameters

Parameter Description
void NA

Return Value

Returns array on success or FALSE on failure.

Example

Following is the usage of this function:

<?php
   $timezone_abbreviations = timezone_abbreviations_list ();
   print_r($timezone_abbreviations["acst"]);
   echo "----------------------------------------------\n";
   
   # Using second function.
   $timezone_abbreviations = DateTimeZone::listAbbreviations();
   
   print_r($timezone_abbreviations["acst"]);
?>

This will produce the following result −

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
        )

)
------------------------------------------------------
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
        )

)

php_function_reference.htm