5 ms·
What's the best .js equivalent?
by jeffrogers 6y ago
What's the best .js equivalent?
- scott_w 6y agoI’ve usually used moment.js in the past (https://momentjs.com/ https://momentjs.com/).
- folkrav 6y agomoment.js is in maintenance mode and the library authors themselves try to push people away to other libs[1]. Seems like most people have moved to date-fns or day.js. Moment authors seem to point to Luxon, which I didn't know about. [1] https://momentjs.com/docs/#/-project-status/ https://momentjs.com/docs/#/-project-status/
- scott_w 6y agoYep, I was aware that they moved to maintenance mode but I mistakenly thought they were still good for new projects.
- Brendinooo 6y agoEither that or https://date-fns.org/ https://date-fns.org/
- fiddlerwoaroof 6y agoI’ve evaluated a bunch and there’s no clear winner: luxon is probably my favorite that I’ve used, but it’s missing some crucial locale stuff. I’ve never used it, but I think js-joda looks the best in paper: it’s based on the API for a fairly popular JVM date library which I used a lot. One issue, though, is that the “correct” date-time representation is often use-case dependent.
- LaundroMat 6y agoI like dayjs best. https://day.js.org/ https://day.js.org/
- qwertox 6y agoI switched to dayjs after using momentjs for many years. Im happy about that switch, the only thing that bothers me a bit is that essential things like UTC, timezones, durations are plug-ins. If you're using script-tags with a CDN each plug-in is a HTTP fetch.
- httgp 6y agoThat is probably intentional to keep the core small and lightweight. You can try bundling all the plugins you use during build if you want to reduce the number of fetches.
- aravindet 6y agoNot usable right now, but the TC39 "Temporal" proposal looks promising, fixing a bunch of issues with Date and introducing a clear API: https://tc39.es/proposal-temporal/docs/ https://tc39.es/proposal-temporal/docs/ There is a polyfill, but they recommend against production use.