unix timestamp in javascript
xxxxxxxxxx
// date in milliseconds:
let ms = Date.now();
// date in seconds:
let seconds = Math.round(Date.now()/1000);
xxxxxxxxxx
// Get current timestamp in milliseconds
const timestamp = Date.now();
console.log(timestamp);
xxxxxxxxxx
// Get current timestamp in milliseconds
const timestamp = Date.now();
console.log(timestamp);
// Get current timestamp in seconds
const timestampInSeconds = Math.floor(Date.now() / 1000);
console.log(timestampInSeconds);
xxxxxxxxxx
let exp = (Math.floor(Date.now() / 1000) + 60 * 60)
console.log(exp)
const expirationDate = new Date(exp * 1000);
const formattedDate = expirationDate.toISOString();
console.log(formattedDate);