Carlos Cifuentes
AngularJS library migration · dates

Migrating angular-moment / Moment.js to modern Angular

angular-moment exposed Moment.js through filters like amDateFormat and amTimeAgo. Moment itself is in maintenance mode and its authors recommend alternatives for new work.

What replaces it

OptionWhen to choose it
date-fnsSmall functions, tree-shakeable, works with native Date.
LuxonWhen time zones and durations are central to the product.
Angular DatePipeEnough when you only format dates for display.

How to migrate it

  1. Separate formatting (templates) from date maths (services); they migrate differently.
  2. Replace the am filters with DatePipe or a small custom pipe.
  3. Replace date arithmetic and parsing with date-fns or Luxon, with unit tests around time zones.

Watch out. Moment objects are mutable; the replacements are not. Code that called add or startOf without using the return value changes behavior silently.

Other libraries

Planning a migration or a micro-frontend platform?

In a 20-minute call you describe your situation and I tell you how I'd approach it. If it isn't worth doing yet, I'll say so.

Message me on LinkedIn