Last active
December 23, 2015 08:59
-
-
Save squallstar/6611599 to your computer and use it in GitHub Desktop.
Date UTC timestamp
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
Date.prototype.getUTCTimestamp = function() { | |
var currentTime, localOffset; | |
currentTime = this.getTime(); | |
localOffset = (-1) * this.getTimezoneOffset() * 60000; | |
return Math.round(new Date(currentTime + localOffset).getTime() / 1000); | |
}; |
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
Date::getUTCTimestamp = -> | |
currentTime = @getTime() | |
localOffset = (-1) * @getTimezoneOffset() * 60000 | |
Math.round new Date(currentTime + localOffset).getTime() / 1000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment