talira

A library for working with dates and times in JS

open sourceMITself-hostablefree

Luxon is a JavaScript library for dates and times built around immutable DateTime, Duration and Interval types with an explicit, chainable API. It takes time zones and internationalization from the platform's Intl API, so IANA zones and locale-aware formatting and parsing need no locale or time zone data files. Isaac Cambron, one of Moment's maintainers, wrote it as a modernized Moment, and it lives in the Moment project's GitHub organization. Calendars other than Gregorian and ISO week dates are supported for output only. A new maintainer took over in January 2025 and is planning Luxon 4, which replaces invalid objects with errors.

Problems it solves

  • convert a meeting time between New York and Tokyo in JavaScript without shipping time zone data
  • add a duration to a date and keep the wall-clock time right across daylight saving changes
  • represent a date range and check whether another time falls inside it
  • format dates in each user's locale using the browser's built-in Intl support
  • work out the time between two timestamps as months, days and hours in JS
  • parse ISO 8601, RFC 2822, HTTP and SQL date strings in Node
  • show a date in the Islamic or Japanese calendar on a web page
  • a date API where each method does one explicit thing instead of guessing what I passed
  • find out why a date string in a custom format failed to parse
  • immutable date objects in JavaScript so a shared date can't change under me

Features

  • DateTime, Duration and Interval types
  • immutable, chainable, explicit API
  • IANA time zones through the Intl API, with no time zone data files
  • locale-aware formatting and parsing through Intl, with no locale files
  • parsing ISO 8601, RFC 2822, HTTP and SQL strings and custom formats
  • fromFormatExplain to debug a parse
  • relative time with toRelative and toRelativeCalendar
  • output calendars: Buddhist, Chinese, Hebrew, Islamic, Japanese, Persian and others, where the platform has them
  • ISO week dates
  • throwOnInvalid setting to throw instead of returning invalid objects
View 1 more
  • Info.features() to check what the platform supports

Limitations

  • Can't do date math in non-Gregorian calendars: Islamic, Hebrew, Japanese and other calendars are supported only for formatting1
  • Doesn't parse time zone names or abbreviations like EST or Eastern Standard Time: named offsets are supported only in formatting23
  • No support for Internet Explorer: it officially supports the last two versions of major browsers, and older IE probably won't work at all4

Capabilities

Has an APIplan not known

Alternatives

The same job

These do what Luxon does.

  1. date-fns Modern JavaScript date utility library
  2. Day.js Fast 2kB alternative to Moment.js with the same modern API
  3. Moment.js Parse, validate, manipulate, and display dates in javascript.

Compare Luxon with the top 3