iso8601_timezone_to_offset() - WordPress 函数参考中文文档

返回介绍

iso8601_timezone_to_offset()

发布于 2017-09-11 字数1338 浏览 937 评论 0

iso8601_timezone_to_offset( string $timezone )

Computes an offset in seconds from an iso8601 timezone.


描述


参数

$timezone

(string)
(Required)
Either ‘Z’ for 0 offset or ‘±hhmm’.


返回值

(int|float) The offset in seconds.


源代码

File: wp-includes/formatting.php

function iso8601_timezone_to_offset( $timezone ) {
	// $timezone is either 'Z' or '[+|-]hhmm'
	if ($timezone == 'Z') {
		$offset = 0;
	} else {
		$sign    = (substr($timezone, 0, 1) == '+') ? 1 : -1;
		$hours   = intval(substr($timezone, 1, 2));
		$minutes = intval(substr($timezone, 3, 4)) / 60;
		$offset  = $sign * HOUR_IN_SECONDS * ($hours + $minutes);
	}
	return $offset;
}

更新日志

Version 描述
1.5.0 Introduced.

相关函数

Used By

  • wp-includes/formatting.php:
    iso8601_to_datetime()

User Contributed Notes

上一篇:in_the_loop()

下一篇:iso8601_to_datetime()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!