Skip to content

Instantly share code, notes, and snippets.

@maxfi
Last active June 25, 2019 05:07
Show Gist options
  • Save maxfi/afc43865d2dd9e50f2ec210496dfaf6f to your computer and use it in GitHub Desktop.
Save maxfi/afc43865d2dd9e50f2ec210496dfaf6f to your computer and use it in GitHub Desktop.
Javascript date/time references

date-fns

Moment.js

js-joda

Home

Why yet another javascript date and time library

  • Popular javascript date libraries like moment or date-utils are wrappers around the native javascript Date object, providing syntactic sugar. The native Date object always consist of a date, time and a timezone part. In opposite to that, js-joda is a standalone date and time implementation.
  • The API has a domain-driven design with classes for the different use cases, like LocalDate, ZonedDateTime or Period. For examples LocalDate allows to handle dates like birthdays or holidays in a clean and error-safe way, especially if these dates are persisted to an external server.
  • js-joda is immutable. Immutability aligns well with pure functions and with the architecture of frameworks like React and Flux.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment