PHP | timezone_name_from_abbr() Function
Last Updated :
16 Aug, 2018
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:
<?php
$abbr = timezone_name_from_abbr( "PST" );
echo ( "PST stands for " . $abbr );
?>
|
Output:
PST stands for America/Los_Angeles
Program 2:
<?php
$abbr = timezone_name_from_abbr( "" , 7200, 0);
echo ( "The given parameter stands for " . $abbr );
?>
|
Output:
The given parameter stands for Europe/Helsinki
Related Articles:
Reference: http://php.net/manual/en/function.timezone-name-from-abbr.php
Share your thoughts in the comments
Please Login to comment...