Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 563
Petran Avatar asked Feb 04 '20 13:02

Petran


People also ask

How do you find the difference between two dates in Luxon?

fromISO("2020-09-06T12:00"); const date2 = luxon. DateTime. fromISO("2019-06-10T14:00"); const diff = Interval. fromDateTimes(later, now); const diffHours = diff.

How do you compare date objects?

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).

Can you compare JavaScript dates?

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.


1 Answers

To compare just the dates, use startOf

startDate.startOf("day") <= someDate.startOf("day")
like image 164
snickersnack Avatar answered Sep 20 '22 16:09

snickersnack