Day.js Fast 2kB alternative to Moment.js with the same modern API

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

Our great sponsors
  • SurveyJS - Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • dayjs

    ⏰ Day.js 2kB immutable date-time library alternative to Moment.js with the same modern API

  • Welllll… “works right now” is perhaps an overly strong assertion when it comes to day.js. I tried switching from moment to day.js, and within a couple of hours I’d opened two bugs [1][2], both related to incorrect behaviour in corner cases (like generating the incorrect date when near a daylight saving time transition).

    The fact that it only took me a few hours to find these suggests there are plenty more bugs like these to find. The fact that these bugs have been open since the start of March with no movement on them suggests they aren’t too interested in correct behaviour (or perhaps they’re just your typical under-staffed open source project).

    Maybe I just got super unlucky and ran into the only two bugs here… but it’s not likely.

    Luxon and moment.js both handled these cases perfectly. If you’re looking to move from whatever you’re using now, and you can’t wait for the new standard, I’d pick one of those.

    [1]: https://github.com/iamkun/dayjs/issues/1816

  • Luxon

    ⏱ A library for working with dates and times in JS

  • But how does this compare to Luxon? (https://moment.github.io/luxon/#/why)

  • SurveyJS

    Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.

    SurveyJS logo
  • proposal-temporal

    Provides standard objects and functions for working with dates and times.

  • If you are considering switching to a (different) date library, I would suggest to hold off. ECMAScript is about to introduce a native date and time API that is much better than the current Date functionality. It may also make the need for a third-party date library obsolete (as long as you do not need to parse custom date formats).

    - https://github.com/tc39/proposal-temporal

    - https://github.com/tc39/proposal-temporal#polyfills

    - https://tc39.es/proposal-temporal/

    - https://tc39.es/proposal-temporal/docs/index.html

    - https://github.com/tc39/proposal-temporal/issues/1450

    - https://tc39.es/proposal-temporal/docs/parse-draft.html

    As far as I know, issue #1450 is the last remaining blocker for the standardization. I'd assume that this will be resolved in the next months. So Temporal will likely be officially released with ECMAScript 2023, but browser vendors and other implementors will start shipping it before the offical release.

  • temporal-polyfill

    Polyfill for Temporal (under construction)

  • date-fns

    ⏳ Modern JavaScript date utility library ⌛️

  • I prefer date-fns https://date-fns.org

    It’s functional and tree shakable!

    I’ll have to check out Day.js next time though.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts