light9
9/11/2013 - 1:16 PM

JavaScript works with the number of milliseconds since the epoch whereas most other languages work with the seconds. You could work with mil

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();