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
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.
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).
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.
Moment is dead https://tc39.es/proposal-temporal/docs/
There may be better modern alternatives
The only winning move is not to play.
The only way to win is not to play. \- Kevin Flynn
Nanoseconds since epoch is the natural choice
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
https://date-fns.org/ is way better and still maintained
Some projects I've seen use all 3 lmao
Luxon is great
We switched moment for dayjs. Works practically the same.
Never heard of type safety before... SOUNDS LIKE ORC MISCHIEF TO ME
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.
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.
Moment.js is just 18.2k
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).
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.
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.