• PHP Video Tutorials

PHP timezone_abbreviations_list() Function


Advertisements

Definition and Usage

The timezone_abbreviations_list() function is an alias of DateTimeZone::listAbbreviations(). This function returns the dst, offset and name values of timezones in the form of an array.

Syntax

timezone_abbreviations_list()

Parameters

The timezone_abbreviations_list() function doesn't accept any parameters.

Return Values

This function returns an array containing the list of (dst, offset and name ) values of various timezones. Incase of failure this function returns the boolean value false.

PHP Version

This function was first introduced in PHP Version 5.2.0 and, works with all the later versions.

Example

Following example demonstrates the timezone_abbreviations_list() function −

Live Demo
<?php
   //setting the timezone
   $res = timezone_abbreviations_list();
   print_r($res["acst"]);
?>

This will produce following result −

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

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

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

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

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

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

)

Example

Live Demo
<?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
Advertisements