-(int)compareOneDay:(NSString*)oneDay withAnotherDay:(NSString*)anotherDay
{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormattersetDateFormat:@"yyyy-MM-dd"];
NSDate*dateA = [dateFormatterdateFromString:oneDay];
NSDate*dateB = [dateFormatterdateFromString:anotherDay];
NSComparisonResultresult = [dateAcompare:dateB];
if (result == NSOrderedDescending) {
NSLog(@"oneDay比 anotherDay时间晚");
return1;
}
elseif(result ==NSOrderedAscending){
NSLog(@"oneDay比 anotherDay时间早");
return-1;
}
NSLog(@"两者时间是同一个时间");
return0;
}
网友评论