A WordPress-centric search engine for devs and theme authors



iso8601_timezone_to_offset ›

Since1.5.0
Deprecatedn/a
iso8601_timezone_to_offset ( $timezone )
Parameters:
  • (string) $timezone Either 'Z' for 0 offset or '±hhmm'.
    Required: Yes
Returns:
  • (int|float) The offset in seconds.
Defined at:
Codex:

Computes an offset in seconds from an iso8601 timezone.



Source

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