Skip to content

Instantly share code, notes, and snippets.

@antriver
Created November 24, 2022 19:07
Show Gist options
  • Save antriver/9b6a387c972476719615a1d2e7867116 to your computer and use it in GitHub Desktop.
Save antriver/9b6a387c972476719615a1d2e7867116 to your computer and use it in GitHub Desktop.
Get user's timezone
const getTimezoneName = () => {
try {
return Intl.DateTimeFormat().resolvedOptions().timeZone;
} catch (e) {
console.error('Failed to find the system timezone name.', e);
}
return null;
}
console.log(getTimezoneName()); // e.g. "Europe/Berlin"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment