函数原型
iso8601_timezone_to_offset( string $timezone ): int|float
函数描述
Given an ISO 8601 timezone, returns its UTC offset in seconds.
是否弃用
未弃用
函数参数
-
$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 ( 'Z' === $timezone ) {
$offset = 0;
} else {
$sign = ( '+' === substr( $timezone, 0, 1 ) ) ? 1 : -1;
$hours = (int) substr( $timezone, 1, 2 );
$minutes = (int) substr( $timezone, 3, 4 ) / 60;
$offset = $sign * HOUR_IN_SECONDS * ( $hours + $minutes );
}
return $offset;
}
源码链接
变更日志
| Version | Description |
|---|---|
| 1.5.0 | Introduced. |

