Latest web development tutorials

PHP date_timezone_set () function

PHP Date / Time PHP Date / Time Reference Manual

Examples

DateTime object set the time zone:

<?php
$date=date_create("2013-05-25",timezone_open("Indian/Kerguelen"));
echo date_format($date,"Y-m-d H:i:sP");
?>

Running instance »

Definition and Usage

date_timezone_set () function in the DateTime object's timezone.

grammar

date_timezone_set( object,timezone);

参数 描述
object 必需。规定一个由 date_create() 返回的 DateTime 对象。该函数修改该对象。
timezone 必需。规定一个代表所需时区的 DateTimeZone 对象。

提示: 查看 PHP 中支持的所有时区列表

technical details

return value: Returns the specified format DateTime object. If it fails it returns FALSE.
PHP version: 5.2+
Update log: PHP 5.3.0: the return value from NULL to DateTime.


PHP Date / Time PHP Date / Time Reference Manual