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

查看所有标签

Mastering Bitcoin

Mastering Bitcoin

Andreas M. Antonopoulos / O'Reilly Media / 2014-12-20 / USD 34.99

Mastering Bitcoin tells you everything you need to know about joining one of the most exciting revolutions since the invention of the web: digital money. Bitcoin is the first successful digital curren......一起来看看 《Mastering Bitcoin》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

SHA 加密
SHA 加密

SHA 加密工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具