Compare two dates using swift in ios – iOSTutorialJunction

PHOTO EMBED

Thu Mar 24 2022 00:05:49 GMT+0000 (Coordinated Universal Time)

Saved by @pham24n #swift

let formatter = DateFormatter()
formatter.dateFormat = "dd/MM/yyyy"
let firstDate = formatter.date(from: "8/08/2017")
let secondDate = formatter.date(from: "10/08/2017")

if firstDate?.compare(secondDate!) == .orderedAscending {
    print("First Date is smaller then second date")
}
content_copyCOPY

https://iostutorialjunction.com/2017/10/compare-two-dates-using-swift-in-ios.html