PHP date_timezone_set() 函数

PHP 教程 · 2019-01-24 06:14:20

实例

设置 DateTime 对象的时区:

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

定义和用法

date_timezone_set() 函数 DateTime 对象的时区。

语法

date_timezone_set(object,timezone);

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

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

技术细节

返回值: 返回指定格式的 DateTime 对象。如果失败则返回 FALSE。
PHP 版本: 5.2+
更新日志: PHP 5.3.0:返回值从 NULL 改为 DateTime。

点击查看所有 PHP 教程 文章: https://codercto.com/courses/l/5.html

查看所有标签

Transcending CSS

Transcending CSS

Andy Clarke、Molly E. Holzschlag / New Riders / November 15, 2006 / $49.99

As the Web evolves to incorporate new standards and the latest browsers offer new possibilities for creative design, the art of creating Web sites is also changing. Few Web designers are experienced p......一起来看看 《Transcending CSS》 这本书的介绍吧!

URL 编码/解码
URL 编码/解码

URL 编码/解码

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换