wpseek.com
WordPress开发者和主题制作者的搜索引擎
iso8601_timezone_to_offset › WordPress Function
Since1.5.0
已弃用n/a
› iso8601_timezone_to_offset ( $timezone )
| 参数: |
|
| 返回: |
|
| 定义在: |
|
| 文档: |
Given an ISO 8601 timezone, returns its UTC offset in seconds.
Related Functions: wp_timezone_override_offset, wp_timezone_choice, wp_timezone_string, iso8601_to_datetime, wp_timezone_supported
源码
function iso8601_timezone_to_offset( $timezone ) {
// $timezone is either 'Z' or '[+|-]hhmm'.
if ( 'Z' === $timezone ) {
$offset = 0;
} else {
$sign = ( str_starts_with( $timezone, '+' ) ) ? 1 : -1;
$hours = (int) substr( $timezone, 1, 2 );
$minutes = (int) substr( $timezone, 3, 4 ) / 60;
$offset = $sign * HOUR_IN_SECONDS * ( $hours + $minutes );
}
return $offset;
}