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

PHP timezone_open() Function

PHP timezone_open() Function

PHP timezone_open() function is used to create a new DateTimeZone object. It accepts only a single parameter $timezone which specify the timezone of the new DateTimeZone object to be created. It returns the DateTimeZone object as output on success and False on failure.

Syntax:

timezone_open(timezone);

Parameter Values

Parameter Description
timezone This is a required parameter. This parameter definesthe timezone.

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

<html>
<body>
<?php
echo timezone_name_get(timezone_open("Asia/Kolkata"))."<br>";
echo timezone_name_get(timezone_open("Asia/Hong_Kong"))."<br>";
echo timezone_name_get(timezone_open("Europe/Paris"))."<br>";
echo timezone_name_get(timezone_open("Asia/Tokyo"))."<br>";
echo timezone_name_get(timezone_open("Europe/Monaco"))."<br>";
?>
</body>
</html>
Output:
Asia/Kolkata
Asia/Hong_Kong
Europe/Paris
Asia/Tokyo
Europe/Monaco

Example 2:

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

No Sidebar ads