PHP date_timezone_set() Function
Example
Set the time zone of the DateTime object:
<?php $date=date_create("2016-09-25",timezone_open("Asia/Shanghai")); echo date_format($date,"Y-m-d H:i:sP"); ?>
Definition and Usage
The date_timezone_set() function sets the time zone of the DateTime object.
Syntax
date_timezone_set(object,timezone);
Parameter | Description |
---|---|
object | Required. Specifies by date_create() The DateTime object returned. This function modifies this object. |
timezone |
Required. Specifies the DateTimeZone object representing the required time zone. Tip:View the list of all time zones supported in PHP. |
Technical Details
Return Value: | Returns the modified DateTime object. If it fails, it returns FALSE. |
---|---|
PHP Version: | 5.2+ |
Update Log: | PHP 5.3.0: The return value has changed from NULL to DateTime. |