how to get the timestamp in javascript

JavaScript
const currentTimeInMilliseconds=Date.now(); // unix timestamp in millisecondsconst currentTimeInSeconds=Math.floor(Date.now()/1000); //unix timestamp in secondsvar currentTimeInSeconds=Math.floor(Date.now()/1000); //unix timestamp in seconds
var currentTimeInMilliseconds=Date.now(); // unix timestamp in millisecondsnew Date().getTime()

new Date().valueOf()
Source

Also in JavaScript: