我想通过将 NSDate 与当前日期进行比较来检查 NSDate 是否早于(过去)。我该怎么做?
谢谢
最佳答案
我找到了 earlierDate
方法。
if date1.earlierDate(date2).isEqualToDate(date1) {
print("date1 is earlier than date2")
}
您还有 laterDate
方法。
Swift 3 到 swift 5:
if date1 < date2 {
print("date1 is earlier than date2")
}
关于ios - 检查日期是否早于当前日期(Swift),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26807416/