PHP timezone_name_get() Function
The PHP timezone_name_get() function returns the name of the timezone. This function is an alias of DateTimeZone::getName() method.
Syntax
//Object-oriented style public DateTimeZone::getName() //Procedural style timezone_name_get(object)
Parameters
object |
Required. For procedural style only: A DateTimeZone object for which to get a name. |
Return Value
Returns one of the timezone names in the list of timezones.
Example: using both styles
The example below shows the usage of timezone_name_get() function.
<?php //creating a DateTimeZone object $tz1 = timezone_open("Europe/London"); //displaying the name of the timezone //using Object-oriented style echo "The timezone is: ".$tz1->getName()."\n"; //creating a DateTimeZone object $tz2 = timezone_open("America/Chicago"); //displaying the name of the timezone //using Procedural style echo "The timezone is: ".timezone_name_get($tz2)."\n"; ?>
The output of the above code will be:
The timezone is: Europe/London The timezone is: America/Chicago
❮ PHP Date and Time Reference