Skip to main content

Moment.js

Deprecated

Do not use for new projects. Use Luxon as the default replacement. date-fns is an alternative when only a few utility functions are needed. The native Temporal API is an option for projects targeting modern browsers only (~69% global coverage as of May 2026); use @js-temporal/polyfill everywhere else.

What is itโ€‹

Moment.js is a JavaScript date/time library for parsing, validating, manipulating, and formatting dates. It was the standard date library for nearly a decade (2011โ€“2020).

Why it's deprecatedโ€‹

  • Self-declared legacy project โ€” the Moment team says "We now generally consider Moment to be a legacy project in maintenance mode. It is not dead, but it is indeed done."
  • Massive bundle size โ€” doesn't support tree-shaking; adds ~70 KB min+gzip (with locales potentially 230 KB+).
  • Mutable API โ€” Moment objects are mutable, a common source of bugs.
  • Native Temporal API is landing โ€” full support in Chrome 144+, Edge 144+, Firefox 139+ (~69% global coverage as of May 2026).
  • Superior alternatives exist โ€” Luxon (immutable, built-in time zones and i18n, 21 kB), date-fns (modular, tree-shakable), Day.js.

Luxon โ€” the default replacement. Immutable API, built-in time zone and i18n support, and a clean migration path from Moment. date-fns is a lighter alternative when only a few utility functions are needed. The native Temporal API is available in Chrome 144+, Edge 144+, and Firefox 139+ but still lacks Safari support; it is appropriate only for B2B apps with controlled browsers.

Migration pathโ€‹

  1. Replace moment() calls with Luxon's DateTime โ€” see the Luxon migration guide for Moment users
  2. Replace moment.duration() with Duration and moment.range patterns with Interval
  3. Replace moment-timezone usage โ€” Luxon handles IANA time zones natively
  4. Alternative: date-fns โ€” replace moment() calls with date-fns functions (format, addDays, differenceInDays, etc.) if only simple utilities are needed
  5. Alternative: Temporal โ€” use Temporal.PlainDate, Temporal.ZonedDateTime, etc. Use @js-temporal/polyfill for environments without native support
  6. Audit all moment() usage โ€” codemods exist (e.g., moment-to-dayjs-codemod)
  7. Remove moment and moment-timezone from dependencies

Resourcesโ€‹