• PHP Video Tutorials

PHP timezone_identifiers_list() Function


Advertisements

Definition and Usage

The timezone_identifiers_list() function is an alias of DateTimeZone::listIdentifiers(). This function returns all the identifiers in PHP in the form of an array.

Syntax

timezone_identifiers_list([$what, $country])

Parameters

Sr.No Parameter & Description
1

what (Optional)

This is an integer value specifying the DateTimeZone class constant representing a continent.

2

what (Optional)

This is a string value representing a country code(ISO 3166-1).

Return Values

This function returns an array containing the list of timezone identifiers. 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 usage of the function timezone_identifiers_list()

<?php
   print($timeZone[201]."\n");
   print($timeZone[202]."\n");
   print($timeZone[203]."\n");
   print($timeZone[204]."\n");
   print($timeZone[205]."\n");
   print($timeZone[206]."\n");
   print($timeZone[207]."\n");
   print($timeZone[208]."\n");
?>

This will produce following result −

Antarctica/DumontDUrville
Antarctica/Macquarie
Antarctica/Mawson
Antarctica/McMurdo
Antarctica/Palmer
Antarctica/Rothera
Antarctica/Syowa
Antarctica/Troll

Example

$timezone_identifiers = DateTimeZone::listIdentifiers();
for ($i = 0; $i < 5; $i++) {
   echo "$timezone_identifiers[$i]\n";
}
   
echo "-------------------------------------------------\n";
$timezone_identifiers = timezone_identifiers_list();
   
for ($i = 0; $i < 5; $i++) {
   echo "$timezone_identifiers[$i]\n";
}

This will produce the following result −

Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
-------------------------------------------------
Africa/Abidjan
Africa/Accra
Africa/Addis_Ababa
Africa/Algiers
Africa/Asmara
php_function_reference.htm
Advertisements