W3cubDocs

/WordPress

iso8601_timezone_to_offset( string $timezone )

Computes an offset in seconds from an iso8601 timezone.

Description

Parameters

$timezone

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

Return

(int|float) The offset in seconds.

Source

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

Changelog

Version Description
1.5.0 Introduced.

© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/iso8601_timezone_to_offset