joshtronic

in Software Development #JavaScript

Days until Christmas in JavaScript

Time again for one of my holiday cop out posts :)

Here's a couple of ways to calculate the number of days until Christmas:

Vanilla JavaScript

Math.floor((+new Date('2018-12-25') - +new Date()) / 86400000)

Using momentjs

moment('2018-12-25').diff(moment(), 'days')

Merry Christmas!