When comparing Moment.js vs date-fns, the Slant community recommends date-fns for most people. In the question“What are the best JavaScript date formatting libraries?” date-fns is ranked 1st while Moment.js is ranked 2nd. The most important reason people chose date-fns is:
Developers can pick only the functions they need to reduce the size of the library that's being downloaded (using bundlers such as webpack or browserify)
Ranked in these QuestionsQuestion Ranking
Pros
Pro Open source
Moment.js is open source and free to use.
Pro Customizable
Moment allows you to customize almost anything which is very helpful.
Pro Modular
Developers can pick only the functions they need to reduce the size of the library that's being downloaded (using bundlers such as webpack or browserify)
Pro Immutable
Uses pure functions and always returns a new date object to prevent unexpected results.
Cons
Con Relatively big library
The library has to be downloaded in full (currently ~16KB minified and compressed) which includes lots of functions that the user doesn't necessarily need or want.
Con Their "distance in words" function is not very customizable
When comparing a certain date to the current date the function returns a pretty "opinionated" sentence such as "almost 2 years" which can't really be customizable and requires string manipulation to fit result to your needs.
Alternative Products
