iso8601_timezone_to_offset()
iso8601_timezone_to_offset( string $timezone ) 从iso8601…
iso8601_timezone_to_offset( string $timezone )
从iso8601时区计算以秒为单位的偏移量。
Computes an offset in seconds from an iso8601 timezone.
目录锚点:#参数#返回#源码
参数(Parameters)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| $timezone | (string) | 必需 | “Z”表示0偏移或“±hhmm”。 |
返回(Return)
(int|float)以秒为单位的偏移量。
源码(Source)
/**
* Computes an offset in seconds from an iso8601 timezone.
*
* @since 1.5.0
*
* @param string $timezone Either 'Z' for 0 offset or '±hhmm'.
* @return int|float The offset in seconds.
*/
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;
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 1.5.0 | wp-includes/formatting.php:3553 | 0 | 0 |
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。





还没有任何评论,赶紧来占个楼吧!