Comparing NSDates without time component

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

    Two Dates comparisions in swift.

        // Date comparision to compare current date and end date.
        var dateComparisionResult:NSComparisonResult = currentDate.compare(endDate)
    
        if dateComparisionResult == NSComparisonResult.OrderedAscending
        {
            // Current date is smaller than end date.
        }
        else if dateComparisionResult == NSComparisonResult.OrderedDescending
        {
            // Current date is greater than end date.
        }
        else if dateComparisionResult == NSComparisonResult.OrderedSame
        {
            // Current date and end date are same.
        }
    

提交回复
热议问题