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?
fromISO("2020-09-06T12:00"); const date2 = luxon. DateTime. fromISO("2019-06-10T14:00"); const diff = Interval. fromDateTimes(later, now); const diffHours = diff.
The date object allows us to perform comparisons using the > , < , = , or >= comparison operators, but not the equality comparison operators like == , != , === , and !== (unless we attach date methods to the date Object).
In JavaScript, we can compare two dates by converting them into numeric values to correspond to their time. First, we can convert the Date into a numeric value by using the getTime() function. By converting the given dates into numeric values we can directly compare them.
To compare just the dates, use startOf
startDate.startOf("day") <= someDate.startOf("day")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With