Created
April 17, 2012 13:28
-
-
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
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
/* | |
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