Skip to main content Accessibility Feedback

JavaScript and dates revisited

Two quick things…

1. A correction #

In last week’s post on checking if a date is valid with JavaScript, I incorrectly said you needed to pass in the month as a 011 integer (example, March is 2).

This is incorrect. The function automatically adjusts the date for you. I updated the original post accordingly.

2. A helper library #

If you need to do extensive work with dates, reader Erik Grubaugh recommended Moment.js.

It’s a library that makes it easier to get, set, manipulate, and display dates with JavaScript. It looks awesome, but at 126kb, it’s rather large (almost as big as jQuery), so I’d only recommend using it if you’re doing a lot of date work.


🚀 Make 2018 the year you master JavaScript! My pocket guides and mini courses are short, focused, and made for beginners. You can do this!

Have any questions or comments about this post? Email me at chris@gomakethings.com or contact me on Twitter at @ChrisFerdinandi.

Get Daily Developer Tips