IANA Timezone Identifier Regex for JavaScript
/^(?:Africa|America|Antarctica|Arctic|Asia|Atlantic|Australia|Europe|Indian|Pacific|Etc)/[A-Za-z0-9_+\-]+(?:/[A-Za-z0-9_+\-]+)?$/What this pattern does
This page provides a comprehensive, battle-tested regular expression for matching iana timezone identifier, ported and verified for JavaScript. A rigorously tested regex reduces debugging time and protects your application from edge-case failures. The snippet below is ready to drop into your JavaScript project — whether you're validating in an Express middleware, a Next.js API route, or a client-side form.
Javascript Implementation
// IANA Timezone Identifier
// ReDoS-safe | RegexVault — Localization > Time Formats
const ianaTimezoneIdentifierRegex = /^(?:Africa|America|Antarctica|Arctic|Asia|Atlantic|Australia|Europe|Indian|Pacific|Etc)\/[A-Za-z0-9_+\-]+(?:\/[A-Za-z0-9_+\-]+)?$/;
function validateIanaTimezoneIdentifier(input: string): boolean {
return ianaTimezoneIdentifierRegex.test(input);
}
// Example
console.log(validateIanaTimezoneIdentifier("America/New_York")); // trueTest Cases
Matches (Valid) | Rejects (Invalid) |
|---|---|
America/New_York | EST |
Europe/London | UTC+8 |
Asia/Singapore | New_York |
Asia/Kolkata | America/New York |
Australia/Sydney | America/ |
Pacific/Auckland | US/Eastern |
Etc/UTC | — |
When to use this pattern
This pattern is drawn from the Localization > Time Formats category and carries a ReDoS-safe certification. That matters for JavaScript developers because especially critical in long-running Node.js event loops where a ReDoS vulnerability can block the entire process. RegexVault audits patterns against known backtracking attack vectors, ensuring you have the necessary context before using this regex in a high-stakes production environment.
Common Pitfalls
IANA zone names can change when countries change their timezone rules. The tzdb is updated multiple times per year. Always use the latest version in your runtime.
Technical Notes
IANA timezone database (TZDB/Olson database) is the global standard. Format: Area/Location or Area/Location/Subzone. Etc/* zones are for UTC offsets. US/*, Canada/*, US/Eastern are deprecated aliases.
Have a pattern that belongs in the vault?
Submit it for review — community-verified patterns get credited to your GitHub handle. Free submissions join the queue. Priority review available for $15.
Submit a Pattern