Swift version: 5.2
Date struct conforms to both
Comparable, which means you check two dates for equality and compare them to see which is earlier.
In practice, this means you can use
== to compare them just like you would do with strings and integers. Try this in a playground:
let now = Date() let soon = Date().addingTimeInterval(5000) now == soon now != soon now < soon now > soon
SPONSORED Announcing NSSpain 2020: Remote Edition! An online, continuous conference for iOS developers. We’ll start on Thursday and finish on Friday, with talks, activities, and lots of fun for 36 hours, non-stop. Sound good? Join us!
Available from iOS 8.0
This is part of the Swift Knowledge Base, a free, searchable collection of solutions for common iOS questions.
Link copied to your pasteboard.