19 lines
564 B
JavaScript
19 lines
564 B
JavaScript
const before = new Date("August 1 2022 7:30:35")
|
|
const now = new Date();
|
|
|
|
// console.log(now.getTime(), before.getTime());
|
|
|
|
const difference = now.getTime() - before.getTime();
|
|
console.log(difference);
|
|
|
|
const mins = Math.round((difference / 1000) / 60);
|
|
|
|
const hours = Math.round(mins / 60);
|
|
const days = Math.round(hours / 24);
|
|
|
|
console.log(`mins: ${mins}, hours: ${hours}, days: ${days}`)
|
|
console.log(`The blog was written ${days} ago`)
|
|
|
|
// converting timestaps into Date Object
|
|
const timestamp = 1659331835000;
|
|
console.log(new Date(timestamp)) |