Questions tagged [luxon]

Luxon is a date and time library for JavaScript, and the successor to Moment.js.

Luxon is a date and time library for JavaScript. It is the successor to Moment.js, and is preferred over Moment by both libraries maintainers.

Luxon derives its time zone data from the ECMAScript Intl APIs, giving it full time zone support in modern browsers without having to supply a separate data file (like Moment).

References:

260 questions
67
votes
34 answers

Difference between two dates in years, months, days in JavaScript

How to get the difference between two dates in years, months, and days in JavaScript, like: 10th of April 2010 was 3 years, x month and y days ago? There are lots of solutions, but they only offer the difference in the format of either days OR…
Chris
  • 3,756
  • 7
  • 35
  • 54
41
votes
2 answers

How to calculate a duration between two dates in luxon?

Luxon's documentation for the Duration.fromISO method describes it as Create a Duration from an ISO 8601 duration string Nowhere is mentioned the ability to create a duration based on two dates. My typical use case would be: "did the event between…
WoJ
  • 27,165
  • 48
  • 180
  • 345
37
votes
6 answers

compare only dates with luxon Datetime

I have two luxon objects, let startDate = DateTime.fromISO(startDate) let someDate = DateTime.fromISO(someDate) How can I compare if someDate is <= startDate, only the dates, without the time?
Petran
  • 7,677
  • 22
  • 65
  • 104
19
votes
2 answers

How to format a Date with Luxon?

With moment.js, you can format a date this way: const date = moment("2010-10-22T21:38:00"); const data = date.format("LL - LT") console.log(data)