JavaScript Get the current timestamp:
First method:
var timestamp = Date.parse (new Date());
Result: 1280977330000
Second method:
var timestamp = (new Date()).valueOf();
Result: 1280977330748
Third method:
var timestamp=new Date().getTime();
Result: 1280977330748
The first type: the timestamp obtained is to change the millisecond to 000 for display.
The second and third types are to obtain the timestamp of the current millisecond.
The above is the detailed content of Three ways to get the current timestamp in JS. For more information, please follow other related articles on the PHP Chinese website!