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.

About Josh

Husband. Father. Pug dad. Musician. Founder of Holiday API, Head of Engineering and Emoji Specialist at Mailshake, and author of the best damn Lorem Ipsum Library for PHP.

Currently Reading

Parasie Eve

Previous Reads

Buy Me a Coffee Become a Sponsor

Related Articles