Days until Christmas in JavaScript

Josh Sherman
1 min read
Software Development 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!

Join the Conversation

Good stuff? Want more?

Weekly emails about technology, development, and sometimes sauerkraut.

100% Fresh, Grade A Content, Never Spam.

Related Articles