playground/js/date-difference/index.js

11 lines
389 B
JavaScript
Raw Normal View History

2023-04-13 15:20:49 +00:00
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);