判斷兩個日期是否同一天
NSCalendar *calendar = [NSCalendar currentCalendar];
unsigned unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay;
// 要比較的那個日期级乐,NSDate類型
NSDateComponents* comp1 = [calendar components:unitFlags fromDate:createOrderTime];
// 跟現(xiàn)在的時間相比
NSDateComponents* comp2 = [calendar components:unitFlags fromDate:now];
BOOL isSameDay = [comp1 day] == [comp2 day] && [comp1 month] == [comp2 month] && [comp1 year] == [comp2 year];
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者