English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic PHP Tutorial

Advanced PHP Tutorial

PHP & MySQL

PHP Reference Manual

Usage and example of PHP timezone_name_from_abbr() function

PHP Date & Time Function Manual

The timezone_name_from_abbr() function returns the abbreviation form of the timezone name

Definition and usage

Thetimezone_name_from_abbr()function to get the name of a timezone with an abbreviation.

Syntax

timezone_name_from_abbr($abbr, [$gmtoffset[, $isdst]]);

Parameter

Serial numberParameters and descriptions
1

abbr (required)

This is a string value representing the abbreviation of the timezone you need to know the name of.

2

gmtOffset (optional)

This is an integer value representing the offset from GMT (in seconds). If a value is provided, it will search for the timezone and return. If not found, it will return the first found timezone (based on the given abbreviation).

3

isdst (optional)

This is an integer value that specifies the daylight saving time indicator for the timezone.

  • Default is-1, it means that the search does not consider whether the timezone uses daylight saving time.

  • , it assumes that gmtoffset is the offset that is in effect during daylight saving time.1If set to

  • If set to 0, it assumes that gmtoffset is the offset that is not in effect during daylight saving time.

  • If abbr does not exist, it will only search for the timezone through gmtoffset and isdst.

Return value

The PHP timezone_name_from_abbr() function returns a string value representing the timezone name. If it fails, this function returns a boolean valuefalse.

PHP version

This function was originally introduced in PHP version5.2introduced in version 5.2.0 and is available in all higher versions.

Online example

The following examples demonstratetimezone_name_from_abbr()Usage of the function timezone_name_from_abbr() to return the timezone name based on the timezone abbreviation-

<?php
   $res = timezone_name_from_abbr("PST");   
   print($res);
?>
Test and see‹/›

Output result

America/Los_Angeles

Online example

You can also get the timezone name by passing the offset value in the following format-

<?php
   //Set timezone
   $res = timezone_name_from_abbr("", 3600, 0);   
   print($res);
?>
Test and see‹/›

Output result

Europe/Paris

Online example

Returns the timezone name based on the timezone abbreviation

<?php
echo timezone_name_from_abbr("CET")."\n";
echo timezone_name_from_abbr("", 3600, 0);
?>
Test and see‹/›

Output result:

Europe/Berlin
Europe/Paris