Comparing NSDates without time component

后端 未结 17 1677
轮回少年
轮回少年 2020-11-27 12:49

In a swift playground, I have been using

NSDate.date() 

But, this always appears with the time element appended. For my app I need to ignor

17条回答
  •  渐次进展
    2020-11-27 13:01

    For Swift3

    var order = NSCalendar.current.compare(firstDate, to: secondDate, toGranularity: .hour)
    
    if order == .orderedSame {
        //Both the dates are same. 
        //Your Logic.
    }
    

提交回复
热议问题