PHP timezone_open() Function

PHP timezone_transitions_get() Function
PHP timezone_offset_get() Function

We have been learning a lot about the timezone functions in PHP. In this article,
you will learn how to create a new timezone object. The timezone_open() function in PHP
creates and return new DateTimeZone object.

What is the syntax of the timezone_open() function in PHP?

Procedural syntax

timezone_open(timezone)

Object-oriented syntax

DateTimeZone::__construct(timezone)

Both of the above syntaxes produce the same results. The first is without using the class and
the second use the DateTimeZone class to call the method.

ParameterDetails
timezoneTimezone – Required
PHP timezone_open() method

Example of the timezone_open() function

Example 1. In this example, we create the new timezone object for the Europe/Paris region. Then, we get the name of this timezone using the timezone_name_get() method.

<?php
$timezone=timezone_open("Europe/Paris");
echo timezone_name_get($timezone);
?>
PHP timezone_transitions_get() Function
PHP timezone_offset_get() Function
en English
X
Scroll to Top