4 best JavaScript date libraries

Stacy Cho
Web Developers Tomorrow
4 min readJun 2, 2020

TLDR;

The best JavaScript date libraries in 3 different criteria is summarized at the bottom [Conclusion section]

The most popular package

Moment.js 👏

12M weekly Downloads

The lightest package

dayJS 👏

471 KB

The most stable package

Moment.js 👏

9 years

Moment.js

Moment.js is one the oldest and best known date — related libraries for both Node.js and vanilla Javascript (making it browser compatible)

Weekly Downloads *NPM

12M

License

MIT

Package Size (Unpacked Size)

40.9 MB

Initial Release Date

Version 1.1.0 release Date — — — 9 Years ago

Current Version — — — 2.26.0

UPs 👍

  • available in many different environments and different package managers including npm , yarn , NuGet, spm, meteor
  • very stable and reliable; been used by many software engineers for more than 9 years
  • very good browser compatibility; available in Windows 7

DOWNs 👇

  • It is slow

It took Moment.js almost 9 seconds to parse 100 000 ISO 8601 dates, while Day.js needs only 0.5 seconds

  • It is heavy

Longer loading time means lower user experience and worse SEO

Cheatsheet

Parsing

Formatting

Add

Internationalization

date-fns

date-fns provides the most comprehensive, yet simple and consistent toolset for manipulating JavaScript dates in a browser & Node.js

Weekly Downloads *NPM

6M

License

MIT

Package Size (Unpacked Size)

11 MB

Initial Release Date

Version 0.1.0 release Date — — — 6 Years ago

Current Version — — — 2.14.0

UPs 👍

  • All functions are grouped by file, allowing users to import just what you need. Optimization especially for front-end developers
  • good internationalization; support a total of 57 different locales

Cheatsheet

compareDesc

format / internationalization

format Distance

dayJS

DayJS is a.k.a minified version of Moment.js. DayJS uses the same API of Moment.js but reduces its file size by 97%

Weekly Downloads *NPM

2M

License

MIT

Package Size (Unpacked Size)

471 KB

Initial Release Date

Version 1.0.0 release Date — — — 2 Years ago

Current Version — — — 1.8.27

UPs 👍

  • very light; while Moment.js full minified file weights a total of 67.9KB, DayJS minified file is only 2kb while supporting core functions of Moment.js (internationalization, plugins etc…)
  • Moment.js-compatible API; basically if you use Moment.js, you already know how to use Day.js

Cheatsheet

add / substract

format

Luxon

Luxon provides a much easier and comprehensive interface than the native types it wraps

Weekly Downloads *NPM

60K

License

MIT

Package Size (Unpacked Size)

2.96 MB

Initial Release Date

Version 0.0.1 release Date — — — 3 Years ago

Current Version — — — 1.24.1

UPs 👍

  • All objects are immutable; easy to debug (Moment.js mutates the object)
  • relies heavily on the Intl API from modern browsers; do not need extra configuration files to deal with locales

DOWNs 👇

  • do not support all features Moment.js support
  • not compatible with older browsers; need polyfill

Cheatsheet

Internationalization

parse from ISO 8601

CONCLUSION

POPULARITY RANKING

PACKAGE SIZE RANKING (desc.)

RELEASE DATE RANKING (asc.)

Happy Coding 🙌

Photo by Arif Riyanto on Unsplash

--

--