JavaScript › Date, Time & Internationalization (Intl API)
How do you calculate the difference between two dates in days?
IntermediateAnswer
Subtracting two Date objects (or calling getTime() on each) yields the difference in milliseconds; divide by the number of milliseconds in a day (1000*60*60*24) to get whole days.
const start = new Date('2026-08-01');
const end = new Date('2026-08-08');
const days = (end - start) / (1000*60*60*24); // 7Real-world example Calculating how many days remain until a subscription renews.