Luxon is a library for dealing with dates and times in JavaScript.
Features
- A nice API for working with datetimes
- Interval support (from time x to time y)
- Duration support (14 days, 5 minutes, 33 seconds)
- Parsing and Formatting datetimes, intervals, and durations
- Internationalization of strings using the Intl API
- Detailed and unambiguous math operations
- Built-in handling of time zones
- Partial support for multiple calendar systemsFor more, see the docs on the left, including the api docs
The most important class in Luxon is DateTime
. A DateTime represents a specific millisecond in time, along with a time zone and a locale. Here’s one that represents May 15, 2017 at 8:30 in the morning:
const dt = DateTime.local(2017, 5, 15, 8, 30);
DateTime.local takes any number of arguments, all the way out to milliseconds. Underneath, this is similar to a JavaScript Date object. But we’ve decorated it with lots of useful methods.