3 ms·
JS's built in date formatting/handling is terrible and often do what needs to be one. MomentJS may be a giant import, but it works an it works really well.
by com2kid 6y ago
JS's built in date formatting/handling is terrible and often do what needs to be one.
MomentJS may be a giant import, but it works an it works really well.
- jakobloekke 6y agoIt’s the closest thing we have to a useful standard library. Date handling in js without a library is a code smell.
- lol636363 6y agoI am confused, are you using MomentJS for fancy output like 3 days ago etc or for simple output like 5/31/2020? I can see how it is useful in former case but seems overkill in later case.
- runarberg 6y agoSafari is lacking in support (again) but we have `Intl.RelativeTimeFormat`[1] new Intl.RelativeTimeFormat("default").format(-3, "day") 1: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/RelativeTimeFormat/RelativeTimeFormat https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- runarberg 6y agoFormatting is fine. Take a look at `Intl.DateTimeFormat`[1]. Then there is a proposal for `Temporal`[2] which will make handling a lot easier. [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... [2]: https://github.com/tc39/proposal-temporal https://github.com/tc39/proposal-temporal