Comparing NSDates without time component

后端 未结 17 1673
轮回少年
轮回少年 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:14

    When you NSDate.date() in the playground, you see the default description printed. Use NSDateFormatter to print a localized description of the date object, possibly with only the date portion.

    To zero out specific portions of a date (for the sake of comparison), use NSDateComponents in conjunction with NSCalendar.

提交回复
热议问题