PHP date_timezone_set() function

PHP date_timezone_get() function
Date function of PHP

In this article, you will learn how to set the timezone for a date. The date_timezone_set() function set the time zone for the given DateTime object.

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

date_timezone_set(object, timezone)
ParameterDescription
objectRequired. Specifies a DateTime object returned by date_create(). This function modifies this object
timezoneRequired. Specifies a DateTimeZone object that represents the desired time zone.
PHP date_timezone_set() method

Example of the date_timezone_set() function

Example 1. In this example, we create a DateTime object using date_create() method and then set the timezone for it.

<?php
$d=date_create("2014-06-15",timezone_open("Europe/Paris"));
echo date_format($d,"Y-m-d H:i:sP");
?>

PHP date_timezone_get() function
Date function of PHP

Stay up-to-date about PHP!

We don’t spam!

en English
X
Scroll to Top