Passing Moment, Or Moment.js Replacement

web development

The problem

At some point while dealing with date/time in JS code and searching for some clues, I stumbled over an advice "just use Moment" - and at that time, it was quite revelatory - I wasn't much used to the npm "package for everything" attitude, and haven't really thought that so many problems could have been solved by just using the right library.

And Moment.js stuck with me ever since - not that I needed day/time parsing or manipulation every day, but when I did need it, the answer was clear - just use Moment!

So it was quite a surprise to me that it's being deprecated - in fact, has been for quite some time already. The obvious questions were "why?" and "what now?".


Apparently Model.js has aged and doesn't do as good a job as it did before - as the maintainers say at the,

Moment was built for the previous era of the JavaScript ecosystem. The modern web looks much different these days. Moment has evolved somewhat over the years, but it has essentially the same design as it did when it was created in 2011.

Some of the problems one could fin on the Web is slowness, large size, mutability and debugging problems. For instance, there's a good comparison of the Moment against other libraries (and native solution) at - it's actually from pre-deprecation times, but I'd expect it still holds true:

Moment.js performance comparison

What now?

There's a "recommendations" section on the Moment's website itself:, which list several alternatives, such as:

It's almost too much choice, but luckily that pre-deprecation article I've mentioned earlier has als a comparison of these alternatives considering certain functionality and size:

Date/time libraries comparison

Which (among some suggestions elsewhere) points out that for general cases, Day.js or date-fns are probably the best choice, while for tricky cases and error-prone data Luxon might be a better choice.