PHP date_timezone_set() Function

❮ PHP Date/Time Reference

Example

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");
?>
Try it Yourself »

Definition and Usage

The date_timezone_set() function sets the time zone for the DateTime object.


Syntax

date_timezone_set(object, timezone)

Parameter Values

Parameter Description
object Required. Specifies a DateTime object returned by date_create(). This function modifies this object
timezone Required. Specifies a DateTimeZone object that represents the desired time zone.

Tip: Look at a list of all supported timezones in PHP

Technical Details

Return Value: Returns the DateTime object for method chaining. FALSE on failure
PHP Version: 5.2+
Changelog: PHP 5.3: Changed the return value from NULL to DateTime (on success)

❮ PHP Date/Time Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.