PHP | timezone_name_from_abbr() Function

The timezone_name_from_abbr() function is an inbuilt function in PHP which is used to return the timezone name from abbreviation. The abbreviation is sent as a parameter to the timezone_name_from_abbr() function and it returns the name of the timezone on success or False on failure.

Syntax:

string timezone_name_from_abbr( $abbr, $gmtoffset, $isdst )

Parameters: This function accepts three parameters as mentioned above and described below:



  • $abbr: It is a mandatory parameter which specifies the timezone abbreviation.
  • $gmtoffset: It is an optional parameter which specifies the offset from GMT in seconds. The default value is -1, which means that first found timezone corresponding to abbr is returned.
  • $isdst: It is an optional parameter which specifies the daylight saving time indicator. The default value is -1, which means that whether the timezone has daylight saving or not is not taken into consideration when searching.

Return Value: It returns the name of the timezone on success or False on failure.

Exceptions: The timezone_name_from_abbr() function is an alias of DateTimeZone::listAbbreviations function.

Below program illustrate the timezone_name_from_abbr() function in PHP:

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Displaying the name of timezone using the abbreviation
$abbr = timezone_name_from_abbr("PST");
echo ("PST stands for " . $abbr);
?>

chevron_right


Output:

PST stands for America/Los_Angeles

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Displaying the name of timezone using the abbreviation
$abbr = timezone_name_from_abbr("", 7200, 0);
echo ("The given parameter stands for " . $abbr);
?>

chevron_right


Output:

The given parameter stands for Europe/Helsinki

Related Articles:

Reference: http://php.net/manual/en/function.timezone-name-from-abbr.php



My Personal Notes arrow_drop_up

I am a technology enthusiast who has a keen interest in programming I am pursuing Engineering in Computer Science from GEU, Dehradun I like to unwind by watching movies and English sitcomsI have a keen interest in music

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.