Hacker News new | past | comments | ask | show | jobs | submit login

A good lightweight alternative is js-joda. I recently switched from moment.js and I've been very happy with it.

https://js-joda.github.io/js-joda/




At 43kb gzipped, it's hardly lightweight - that's 70% of moment.js' size, 4x larger than date-fns


js-joda offers a lot more than lightweight native Date type wrappers like date-fns. It offers separate time and date implementations which allows you to more precisely model your problem. The native Date object always consists of a time, date, and timezone.

For example, a js-joda LocalDate is just a date without a time or timezone. This allows you to cleanly represent things like birthdays, anniversaries or holidays in an unambiguous way.

js-joda is also immutable which in my experience is more predictable and less error prone. With js-joda, "d.plusDays(366);" leaves d unchanged.

js-joda also has very good duration support.

Because it does not use the native Date implementation it is potentially more consistent across platforms. It is also has lots of tests.

If all you are doing is formatting a few dates, date-fns is probably sufficient and it is certainly smaller, but for more intensive manipulations of dates and times I think js-joda is well worth the size.


Just like the OG Joda, I'm assuming it doesn't support nanosecond time resolution?




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: