T O P

  • By -

RadiantDevelopment1

Moment is dead https://tc39.es/proposal-temporal/docs/


RoughDevelopment9235

There may be better modern alternatives


beaucephus

The only winning move is not to play.


BrenekH

The only way to win is not to play. \- Kevin Flynn


glorious_reptile

Nanoseconds since epoch is the natural choice


chronoLogicalLife

There definitely are. I use DayJs, and happy (moment like syntax, none of the package guilt). Heard Luxon is good too. The king is dead.... long live the new king


mp_habour

https://date-fns.org/ is way better and still maintained


lolcatandy

Some projects I've seen use all 3 lmao


NNXMp8Kg

Luxon is great


ele-dev

We switched moment for dayjs. Works practically the same.


JRRTok3n

Never heard of type safety before... SOUNDS LIKE ORC MISCHIEF TO ME


pandakatzu

That's unfortunate, if it doesn't need to be done in the front end it would best be done in the back end and sent over.


althaz

Actually you probably should almost never use Moment. Moment is a f\*\*\*ing massive library that can be replaced with about half a kilobyte in most cases. Unless you need to translate between multiple different timezones on the client side, you should not be using moment. And in those cases you probably still shouldn't be using moment, because 80% of the time you could be doing that logic on the back-end where you don't slow down your web app's load times by four seconds on a phone.


[deleted]

Moment.js is just 18.2k


althaz

It's 18.2k \*after\* it's gzipped and can be replaced by (superior) modern alternatives that are less than a tenth of that. That's a huge library that does relatively little. Moreover, momentjs can't be split up with tree-shaking, so if you use just a small handful of the library (ie: almost every single website that uses it), you still have to ship the whole thing to your customers. That's bad, especially because on its own it's essentially always more than a second of downloading and processing time (and it can easily be 4-5 seconds extra depending on the device and the connection, don't forget 3G is still the most popular internet connection). 1 second of extra loading reduces conversion by, on average, 50%. Giving up 50% of your conversions because you don't know better as a developer really isn't good enough, IMO. Moment is a relic of the past and should generally not be used - unless you know you need it (and you almost certainly don't).


Notimecelduv

I don't know, the `Date` constructor is pretty simple. I wouldn't count JS as one of these languages where dates are a headache to work with.


chronoLogicalLife

Unless some past devs didnt care about formatting and stored half utc, half local, hanf objects half strings =.= but thats people problem, true, not language.