• PHP Video Tutorials

PHP timezone_name_from_abbr() Function


Advertisements

Definition and Usage

The timezone_name_from_abbr() function is used to get the name of a timezone from an abbreviation.

Syntax

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

Parameters

Sr.No Parameter & Description
1

abbr (Mandatory)

This is a string value representing the abbreviation for which you need to know the name of the time zone .

2

gmtOffset (Optional)

This is an integer value representing an offset from GMT in seconds. If a value for this is given then its timezone is searched and returned. If not found first found timezone (according to given abbreviation) is returned.

3

isdst (Optional)

This is an integer value specifying the daylight saving of the timezone. If value passed for this parameter is 0 it indicates that there is no daylight saving, if it is 1 there is a dalight saving and, if it is 0 the day light saving is not considered.

Return Values

PHP timezone_name_from_abbr() function returns a string value, representing the name of a time zone. Incase of failure this function returns the boolean value false.

PHP Version

This function was first introduced in PHP Version 5.2.0 and, works with all the later versions.

Example

Following example demonstrates the usage of the timezone_name_from_abbr() function −

Live Demo
<?php
   $res = timezone_name_from_abbr("PST");   
   print($res);
?>

This will produce following result −

America/Los_Angeles

Example

You can also get the timezone name by passing the offset value as −

Live Demo
<?php
   //setting the timezone
   $res = timezone_name_from_abbr("", 3600, 0);   
   print($res);
?>

This will produce following result −

Europe/Paris

Example

echo timezone_name_from_abbr("CET")."\n";
echo timezone_name_from_abbr("", 3600, 0);

This will produce the following result −

Europe/Berlin
Europe/Paris
php_function_reference.htm
Advertisements