Created
December 7, 2012 22:12
-
-
Save robertlong/4236932 to your computer and use it in GitHub Desktop.
Timezone Abbreviation
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
//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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can obviously be refined more. But, it serves it's purpose fairly well.