Monday 26 August 2013

PHP Function timezone_abbreviations_list()

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.

Paramters

ParameterDescription
voidNA

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

)

No comments:

Post a Comment