iOS: Compare two NSDate-s without time portion

前端 未结 5 1769
谎友^
谎友^ 2020-12-02 17:22

I want to compare two dates: date1 and date2

2011-06-06 12:59:48.994 Project[419:707] firstDate:2011-06-06 10:59:21 +0000
2011-06-06 12:59:49.004 Project[419         


        
5条回答
  •  失恋的感觉
    2020-12-02 17:54

    Okay, so it's a few years after the original question was asked, but it's probably worth mentioning that NSCalendar now has a number of methods that make certain date comparison questions much more straight-forward:

    NSCalendar *currentCalendar = [NSCalendar currentCalendar];
    Bool sameDay = [currentCalendar isDate:dateA inSameDayAsDate:dateB];
    

提交回复
热议问题