Created
April 20, 2013 13:27
-
-
Save jacobbubu/5425979 to your computer and use it in GitHub Desktop.
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
localOffset = (new Date).getTimezoneOffset() * 60000 | |
getLocaleStringByTimezoneOffset = (date, offset) -> | |
localTime = date.getTime() | |
utc = localTime + localOffset | |
offsetDate = utc + 3600000 * offset | |
nd = (new Date(offsetDate)) | |
nd.toLocaleDateString() + ' ' + nd.toLocaleTimeString() | |
d = new Date() | |
console.log 'Beijing Time', getLocaleStringByTimezoneOffset d, 8.0 | |
console.log 'Tokyo Time', getLocaleStringByTimezoneOffset d, 9.0 | |
console.log 'Seattle Time', getLocaleStringByTimezoneOffset d, -8.0 | |
console.log 'Australia Time', getLocaleStringByTimezoneOffset d, 11.0 | |
console.log 'Hawaii Time', getLocaleStringByTimezoneOffset d, -10.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment