Regex to Match Timezone Offsets

Validate timezone offset strings in ISO 8601 format including Z for UTC, and +/-HH:MM format from -14:00 to +14:00. Free online regex pattern tester.

Regular Expression

/^(?:Z|[+-](?:0[0-9]|1[0-4]):[0-5][0-9])$/

Token Breakdown

TokenDescription
^Anchors at the start of the string (or line in multiline mode)
(?:Start of non-capturing group
ZMatches the literal character 'Z'
|Alternation — matches the expression before OR after the pipe
[+-]Character class — matches any one of: +-
(?:Start of non-capturing group
0Matches the literal character '0'
[0-9]Character class — matches any one of: 0-9
|Alternation — matches the expression before OR after the pipe
1Matches the literal character '1'
[0-4]Character class — matches any one of: 0-4
)End of group
:Matches the literal character ':'
[0-5]Character class — matches any one of: 0-5
[0-9]Character class — matches any one of: 0-9
)End of group
$Anchors at the end of the string (or line in multiline mode)

Detailed Explanation

This regex validates timezone offset strings as defined in the ISO 8601 standard. Here is the token-by-token breakdown:

^ — Anchors the match at the start of the string.

(?: — Opens a non-capturing group for the two format alternatives.

Z — First alternative: matches the literal Z character representing Coordinated Universal Time (UTC). This is the simplest timezone designator, commonly called Zulu time.

| — Alternation operator.

[+-] — Matches either a plus sign (for offsets east of UTC) or a minus sign (for offsets west of UTC).

(?:0[0-9]|1[0-4]) — A non-capturing group matching the hours portion. 0[0-9] matches hours 00-09, and 1[0-4] matches hours 10-14. The maximum offset is 14 hours, covering all existing time zones including UTC+14:00 used by Line Islands.

: — Matches the literal colon separating hours and minutes.

[0-5][0-9] — Matches the minutes portion from 00 to 59. Most timezone offsets use 00, 30, or 45 for minutes, but this allows any valid minute value.

) — Closes the non-capturing group.

$ — Anchors the match at the end of the string.

No flags are used since this validates a single timezone offset string.

Timezone offsets are essential in datetime handling. Common examples include Z (UTC), +00:00 (also UTC), -05:00 (US Eastern), +05:30 (India), +09:00 (Japan), and +14:00 (Line Islands). This pattern is useful for datetime parsing, timezone conversion tools, and API input validation.

Example Test Strings

InputExpected
ZMatch
+05:30Match
-08:00Match
+15:00No Match
ESTNo Match
+00:00Match

Try It — Interactive Tester

//
gimsuy
No matches found.
Pattern: 40 charsFlags: noneMatches: 0

Ctrl+Shift+C to copy regex

Customize this pattern →