Skip to content

Instantly share code, notes, and snippets.

@mark05e
Created January 12, 2022 21:37
Show Gist options
  • Save mark05e/466d267a28077c37327a06ccf138671c to your computer and use it in GitHub Desktop.
Save mark05e/466d267a28077c37327a06ccf138671c to your computer and use it in GitHub Desktop.
Get the current 3 digit timezone name
// 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