compare only dates with luxon Datetime

Petran picture Petran · Feb 4, 2020 · Viewed 21.4k times · Source

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?

Answer

snickersnack picture snickersnack · Feb 10, 2020

To compare just the dates, use startOf

startDate.startOf("day") <= someDate.startOf("day")