PHP date_timezone_set()Functions
PHP Date/Time Reference Manual
Examples
Set the timezone of a DateTime object:
<?php
$date=date_create("2013-05-25",timezone_open("Indian/Kerguelen"));
echo date_format($date,"Y-m-d H:i:sP");
?>
$date=date_create("2013-05-25",timezone_open("Indian/Kerguelen"));
echo date_format($date,"Y-m-d H:i:sP");
?>
Run example »
Definition and Usage
The date_timezone_set() function sets the timezone of the DateTime object.
Syntax
date_timezone_set(object,timezone);
| Parameters | Description |
|---|---|
| object | Required. Specifies adate_create()returned DateTime object. This function modifies the object. |
| timezone | Required. Specifies a DateTimeZone object representing the required timezone. Tip: See the list of all supported timezones in PHP |
Technical Details
| Return Value: | Returns a DateTime object in the specified format. If it fails, returns FALSE. |
|---|---|
| PHP Version: | 5.2+ |
| Changelog: | PHP 5.3.0: The return value was changed from NULL to DateTime. |
PHP Date/Time Reference Manual Other Extensions