date-fns
⏳ Modern JavaScript date utility library ⌛️
date-fns: two hundred functions instead of a date class
The most comprehensive toolset for JavaScript dates, its README claims, and also the simplest and most consistent: over two hundred small functions for browser and Node.js work.
The pitch
date-fns calls itself a modern JavaScript date utility library, and the self description is unusually confident: the most comprehensive, yet simple and consistent toolset for manipulating JavaScript dates in a browser and Node.js, with over 200 functions for all occasions. The repo is TypeScript by primary language, its site is date-fns.org, and it sits around 36,600 stars.
Modular to the point of tree shaking
You import what you need and bundlers drop the rest, with webpack, Browserify, and Rollup all named as supported. For teams watching bundle size, a date library that shrinks itself is half the argument won before anyone discusses the API.
Native dates, left alone
The library works with the date objects JavaScript already has. It does not extend core objects, which sidesteps a whole class of collisions and surprises that older approaches to date handling were known for causing in shared codebases.
Pure functions, new instances
Every operation is immutable in practice because the functions are pure: pass a date in, get a new date instance out, original untouched. Combined with native dates, that makes reasoning about state changes one step shorter than it would otherwise be.
Types and locales
The whole library is written in TypeScript with types the authors describe as handcrafted rather than generated, which matters for autocomplete quality. Dozens of locales ship, and you include only the ones your app actually serves, so the long tail of internationalization data stays out of your bundle.
Community notes