Skip to content

Instantly share code, notes, and snippets.

@robertlong
Created December 7, 2012 22:12
Show Gist options
  • Save robertlong/4236932 to your computer and use it in GitHub Desktop.
Save robertlong/4236932 to your computer and use it in GitHub Desktop.
Timezone Abbreviation
//Find the client's local timezone abbreviation.
//Works in most Timezones/Browsers, falls back to GMT offset if unavailable.
function getTimezoneAbbr (){
var m = new Date().toString().match(/\(([^)]+)\)$/);
if (m) return m[1];
return ((d = (new Date().getTimezoneOffset() / 60) * -1) > 0) ? "GMT +" + d : "GMT " + d
}
@robertlong
Copy link
Author

Can obviously be refined more. But, it serves it's purpose fairly well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment