Hello folks! welcome back to a new edition of our tutorial on PHP. In this tutorial guide, we are going to be studying about the PHP timezone_identifiers_list() Function.
The timezone_identifiers_list() function is an alias of DateTimeZone::listIdentifiers(). It returns all the identifiers in PHP in form of an array.
The timezone_identifiers_list() function is an alias of DateTimeZone::listIdentifiers(). It returns all the identifiers in PHP in form of an array.
Syntax
Following below is the syntax to use this function -
timezone_identifiers_list([$what, $country])
READ: PHP | time() Function
Parameter Details
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 Value
This built-in PHP function returns an array containing the list of timezone identifiers. In the case of failure, this function returns the boolean value false.
PHP Version
This function was first introduced as part of core PHP v 5.2.0 and, it works with all the later versions.
Example1
Below example shows the usage of PHP timezone_identifiers_list() function -
<?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"); ?>
Output
When the above code is executed, it will produce the following result -
Antarctica/DumontDUrville Antarctica/Macquarie Antarctica/Mawson Antarctica/McMurdo Antarctica/Palmer Antarctica/Rothera Antarctica/Syowa Antarctica/Troll
Example2
Try the following 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"; }
Output
When the above code is executed, it 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
Alright guys! This is where we are going to be rounding up for this tutorial post. In our next tutorial, we are going to be discussing about the php timezone_name_from_abbr() Function.
Do feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.
Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.
Thanks for reading and bye for now.
Do feel free to ask your questions where necessary and we will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.
Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.
Thanks for reading and bye for now.