Tom Coomer Tom Coomer - 1 year ago 151
Swift Question

Check if date is before current date (Swift)

I would like to check if a NSDate is before (in the past) by comparing it to the current date. How would I do this?


Answer Source

I find the earlierDate methode.

if Date1.earlierDate(Date2).isEqualToDate(Date1)  {
            print(Date1 is earlier than Date2)

You have also the laterDate

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download