iso8601_timezone_to_offset

函数
iso8601_timezone_to_offset ( $timezone )
参数
  • (string) $timezone Either 'Z' for 0 offset or '±hhmm'.
    Required:
返回值
  • (int|float) The offset in seconds.
定义位置
相关方法
wp_timezone_override_offsetwp_timezone_choicewp_timezone_stringiso8601_to_datetimewp_timezone_supported
引入
1.5.0
弃用
-

iso8601_timezone_to_offset: 这是WordPress中的一个函数,将ISO8601时区字符串转换为UTC偏移量。它可以用来将一个时区字符串转换为与UTC偏移的小时数。

给定一个ISO 8601时区,返回其UTC偏移量,单位为秒。

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;
}

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2026-01-14 14:02:22

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: