The date_timezone_set() function sets the time zone for the DateTime object.
PHP date_timezone_set() Function has the following syntax.
date_timezone_set(object,timezone);
PHP date_timezone_set() Function has the following syntax.
Parameter | Is Required | Description |
---|---|---|
object | Required. | DateTime object returned by date_create(). |
timezone | Required. | DateTimeZone object that represents the desired time zone. |
PHP date_timezone_set() Function returns the DateTime object for method chaining. FALSE on failure.
Set the timezone for the DateTime object:
<?php
$date=date_create("2013-05-25",timezone_open("Indian/Kerguelen"));
echo date_format($date,"Y-m-d H:i:sP");
?>
The code above generates the following result.