Skip to content

Instantly share code, notes, and snippets.

@light9
Created September 11, 2013 13:16
Show Gist options
  • Save light9/6523442 to your computer and use it in GitHub Desktop.
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 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