r/angular • • 4d ago

Moment.js in Angular be like

Post image
17 Upvotes

17 comments sorted by

14

u/Old-Parsley-5826 4d ago

You shouldn't use Moment at all nowadays. Use native APIs like Intl ✌️

2

u/Yutamago 4d ago

I believe moment has been deprecated years ago too. So there's absolutely no reason to use it.

1

u/JeanMeche 4d ago

Intl is an i18n API, you might be thinking of the temporal API.

2

u/Old-Parsley-5826 4d ago

No i meant Intl.DateTimeFormat . This basically replaces the parts where you normally use Moment, to reformat dates 😉

But yes, for some other things you also need Temporal

1

u/gordolfograso 3d ago

I wish but tech lead doesn't nor company wants to expend a second replacing it

1

u/JEHonYakuSha 3d ago

Luxon is the official replacement

2

u/lohnstovinzg 4d ago

thats the first time I see someone repost a post of mineI made that in paint like 4 years ago

2

u/cilulowbisted9 4d ago

Reddit solution: use luxon

3

u/Rusty_Raven_ 4d ago

Luxon is a good replacement, and there's also date-fns.

1

u/geaessnind 4d ago

Why are you using a deprecated lib that actively recommends an alternativeAs the other commenter said, use Luxon.

1

u/AwesomeFrisbee 4d ago

Yeah this had annoyed me too back in the day.

0

u/TCB13sQuotes 4d ago edited 4d ago

Use Day.js, Moment isn't required anymore.

-1

u/Old-Parsley-5826 4d ago

Just another dep which is not necessary. Use native APIs and you're safe without increasing your dep tree

0

u/TCB13sQuotes 4d ago

I don't fully disagree with you but Day.js is very small and it handles a bunch of cases around timezones and calculations that are a pain to deal with plain JS.

1

u/Old-Parsley-5826 3d ago

Yeah, I mean, you can't really give a blanket answer here either. Ultimately, it depends on the application itself. If it's an application with a strong focus on dates, date formatting, and date calculations, then a lightweight library definitely makes sense. Otherwise, though, I generally believe you shouldn't always reach for a different package for every little thing.

0

u/fleumpyfirds1 4d ago

date-fns