compare only dates with luxon Datetime
To compare just the dates, use startOf startDate.startOf(“day”) <= someDate.startOf(“day”)
To compare just the dates, use startOf startDate.startOf(“day”) <= someDate.startOf(“day”)
You could use DateTime‘s .diff (doc) Return the difference between two DateTimes as a Duration. const date1 = luxon.DateTime.fromISO(“2020-09-06T12:00”) const date2 = luxon.DateTime.fromISO(“2019-06-10T14:00”) const diff = date1.diff(date2, [“years”, “months”, “days”, “hours”]) console.log(diff.toObject()) <script src=”https://cdn.jsdelivr.net/npm/luxon@1.25.0/build/global/luxon.min.js”></script>
How precise do you need to be? If you do need to take into account common years and leap years, and the exact difference in days between months then you’ll have to write something more advanced but for a basic and rough calculation this should do the trick: today = new Date() past = new … Read more