solvit.io

Get the current timestamp with JavaScript

Solution #1
// Current date/time timestamp in milliseconds
var timestamp = Date.now();

// Current date/time timestamp in seconds
var timestamp = Math.floor(Date.now() / 1000);
Solution #2

If you need support for ancient browsers:

// Current date/time timestamp in milliseconds
var timestamp = new Date().getTime();
Find more solutions about: , , , ,