playground/js/date-difference/index.js
2023-04-13 17:20:49 +02:00

11 lines
389 B
JavaScript

const differenceInCalendarDays = require('date-fns/differenceInCalendarDays');
const earlier = new Date(2023, 6, 31);
const later = new Date(2028, 6, 1);
const dif = differenceInCalendarDays(later, earlier);
console.log('from:', earlier.toLocaleDateString('en-GB', { dateStyle: 'full' }));
console.log('to:', later.toLocaleDateString('en-GB', { dateStyle: 'full' }));
console.log(dif);