I have two dates and I want to compare it.
How can I compare dates?
I have to date objects. Say modificateionDate
older updatedDate
.
So which is the best practice to compare dates?
Date
now conforms to Comparable
protocol. So you can simply use <
, >
and ==
to compare two Date
type objects.
if modificateionDate < updatedDate {
//modificateionDate is less than updatedDate
}