DEV Community

Cover image for Dates difference
Dezina
Dezina

Posted on

Dates difference

const date1 = new Date('12/13/2021');
const date2 = new Date('12/15/2021');
const diffTime = Math.abs(date2 - date1);
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 *24));
console.log(diffDays);

Top comments (0)