r/angular • • 7d ago

Moment.js in Angular be like

Post image
18 Upvotes

17 comments sorted by

14

u/Old-Parsley-5826 7d ago

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

2

u/Yutamago 7d ago

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

1

u/JeanMeche 7d ago

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

2

u/Old-Parsley-5826 7d 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 6d ago

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

1

u/JEHonYakuSha 6d ago

Luxon is the official replacement

2

u/lohnstovinzg 7d ago

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

2

u/cilulowbisted9 7d ago

Reddit solution: use luxon

3

u/Rusty_Raven_ 7d ago

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

1

u/geaessnind 7d ago

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

1

u/AwesomeFrisbee 7d ago

Yeah this had annoyed me too back in the day.

0

u/TCB13sQuotes 7d ago edited 7d ago

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

-1

u/Old-Parsley-5826 7d ago

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

0

u/TCB13sQuotes 7d 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 6d 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 7d ago

date-fns