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_abbreviations_list() Function.
The built-in timezone_abbreviations_list() function in PHP is an alias of the built-in PHP DateTimeZone::listAbbreviations(). It returns the dst, offset and name values of timezones in the form of an array.
The built-in timezone_abbreviations_list() function in PHP is an alias of the built-in PHP DateTimeZone::listAbbreviations(). It returns the dst, offset and name values of timezones in the form of an array.
Syntax
Following below is the syntax to use this function -
timezone_abbreviations_list()
READ: PHP | time() Function
Parameter Details
This built-in PHP function does not accept any parameters.
Return Value
This built-in PHP function returns an array containing the list of (dst, offset and name) values of various timezones. 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 illustrates the usage of the timezone_abbreviations_list() function -
<?php //setting the timezone $res = timezone_abbreviations_list(); print_r($res["acst"]); ?>
Output
When the above code is executed, it will produce the 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 ) )
Example2
Try the following example -
<?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"]); ?>
Output
When the above code is executed, it 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 ) )
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_identifiers_list() 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.