get timestamp from date js code example
Example 1: javascript timestamp in seconds
const ts = () => Math.floor(new Date().getTime() / 1000);
Example 2: how to get timestamp in javascript of a date object
new Date().getTime()
new Date().valueOf()
Example 3: timestamp to date javascript
let unix_timestamp = 1549312452
var date = new Date(unix_timestamp * 1000);
var hours = date.getHours();
var minutes = "0" + date.getMinutes();
var seconds = "0" + date.getSeconds();
var formattedTime = hours + ':' + minutes.substr(-2) + ':' + seconds.substr(-2);
console.log(formattedTime);