Created
January 12, 2022 21:37
-
-
Save mark05e/466d267a28077c37327a06ccf138671c to your computer and use it in GitHub Desktop.
Get the current 3 digit timezone name
This file contains hidden or 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
// https://stackoverflow.com/a/15304657 | |
// https://stackoverflow.com/questions/1091372/getting-the-clients-time-zone-and-offset-in-javascript | |
// With Options | |
var options = {timeZoneName:'short'}; | |
new Date().toLocaleString('en-US', options).toString().match(/([A-Z]){3}/)[0] | |
// Without Options | |
new Date().toString().match(/\(([A-Za-z\s].*)\)/)[1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment