Skip to content

Instantly share code, notes, and snippets.

@squallstar
Last active December 23, 2015 08:59
Show Gist options
  • Save squallstar/6611599 to your computer and use it in GitHub Desktop.
Save squallstar/6611599 to your computer and use it in GitHub Desktop.
Date UTC timestamp
Date.prototype.getUTCTimestamp = function() {
var currentTime, localOffset;
currentTime = this.getTime();
localOffset = (-1) * this.getTimezoneOffset() * 60000;
return Math.round(new Date(currentTime + localOffset).getTime() / 1000);
};
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