iso8601_timezone_to_offset

Definition:
function iso8601_timezone_to_offset($timezone) {}

Computes an offset in seconds from an iso8601 timezone.

Parameters

  • string $timezone: Either ‘Z’ for 0 offset or ‘±hhmm’.

Return values

returns:The offset in seconds.

Source code

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 * 3600 * ($hours + $minutes);

	}

	return $offset;

}

2075

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: