Home >>PHP Date Time Functions >PHP timezone_name_get() Function

PHP timezone_name_get() Function

PHP timezone_name_get() Function

PHP timezone_name_get() function is used to get the name of the given timezone. It accepts only a single parameter $object which specifies the DateTimeZone object. It returns the name of the given timezone as output on success and False on failure.

Syntax:

timezone_name_get(object);

Parameter Values

Parameter Description
object This is a required parameter. This parameter defines a DateTimeZone object.

Here is an example of timezone_name_get() function in PHP:

<html>
<body>
<?php
$timezone=timezone_open("Asia/kolkata");
echo timezone_name_get($timezone);
?>
</body>
</html>
Output:
Asia/Kolkata

Example 2:

<html>
<body>
<?php
$timezone=timezone_open("America/chicago");
echo timezone_name_get($timezone);
?>
</body>
</html>
Output:
America/Chicago

No Sidebar ads