Find difference between dates in days in Javascript
Easy and right ways to calculate difference between two dates in Javascript. Problem We are given two dates and we have to print the difference between those two dates in days. Since we are given two valid dates, half of our problem is already gone and we have not started yet. Get started Calculate number of days - simple and plain. const from = new Date(2019, 0, 1); const to = new Date(2020, 0, 1); console.log((to - from) / (1000 * 3600 * 24)); // 365 Date in Javascript is in millseconds since 1970. So the difference between two date objects is a big millisecond number. We just convert that to days. ...