Created
November 24, 2022 19:07
-
-
Save antriver/9b6a387c972476719615a1d2e7867116 to your computer and use it in GitHub Desktop.
Get user's timezone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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