PHP timezone_offset_get() 函数

PHP Date / Time 函数


实例

返回相对于 GMT 的时区偏移:

<?php
$tz=timezone_open("Asia/Taipei",NULL);
$dateTimeNY=date_create("now",timezone_open("America/New_York"),NULL);
echo timezone_offset_get($tz,$dateTimeNY,NULL);
?>

定义和用法

timezone_offset_get() 返回相对于 GMT 的时区偏移。


语法

timezone_offset_get(object,datetime,NULL);
参数 描述
object 必需。规定由 timezone_open() 返回的 DateTimeZone 对象。
datetime 必需。规定需要计算偏移的日期/时间。

技术细节

返回值: 若成功则返回以秒为单位的时区偏移,失败则返回 FALSE。
PHP 版本: 5.2+

PHP Date / Time 函数

本教程仅供参考学习,如用于商业带来的问题,本站概不负责。
关注公众号
关注公众号

©2020 IT自习室京ICP备20010815号