Skip to content

Instantly share code, notes, and snippets.

@alchemycs
Created April 17, 2012 13:28
Show Gist options
  • Save alchemycs/2405969 to your computer and use it in GitHub Desktop.
Save alchemycs/2405969 to your computer and use it in GitHub Desktop.
A dead easy way to get unix style timestamp from any javascript Date object
/*
Extends the Date object to get number of seconds since UNIX epoch
instead of milliseconds as with .getTime()
*/
Date.prototype.getTimestamp = function() {
return Math.round(this.getTime()/1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment