Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP date_timezone_set() Function

PHP date_timezone_set() Function

PHP Date/Time PHP Date/Time Reference Manual

Example

Set the time zone of a DateTime object:

Run Example »


Definition and Usage

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

Syntax

date_timezone_set(

object,timezone);

Parameters Description
object Required. Specifies a DateTime object returned by date_create() The DateTime object returned. This function modifies that object.
timezone Required. Specifies a DateTimeZone object representing the desired time zone.
 **提示:** [查看 PHP 中支持的所有时区列表](php-ref-timezones.html) |

Technical Details

Return Value: Returns a DateTime object in the specified format, or FALSE on failure.
PHP Version: 5.2+
Changelog: PHP 5.3.0: The return value changed from NULL to DateTime.

PHP Date/Time PHP Date/Time Reference Manual