Created
September 11, 2013 13:16
-
-
Save light9/6523442 to your computer and use it in GitHub Desktop.
JavaScript works with the number of milliseconds since the epoch whereas most other languages work with the seconds. You could work with milliseconds but as soon as you pass a value to say PHP, the PHP native functions will probably fail. So to be sure I always use the seconds, not milliseconds.
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
//This will give you a Unix timestamp (in seconds): | |
var unix = Math.round(+new Date()/1000); | |
//This will give you the milliseconds since the epoch (not Unix timestamp): | |
var milliseconds = new Date().getTime(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment