NSDateFormatter
*dateFormatter = [[NSDateFormatter
alloc]
init];
[dateFormatter
setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSDate *date = [dateFormatter
dateFromString:[NSString
stringWithFormat:@"%@",unreadmail[j][2]]];
NSDate *date1 = [dateFormatter
dateFromString:[NSString stringWithFormat:@"%@",unreadmail[j+1][2]]];
NSComparisonResult result = [date
compare:date1];
NSComparisonResult result = [date compare:date1];
NSLog(@"date1 : %@, date2 : %@", oneDay, anotherDay);
if (result == NSOrderedDescending)
{
//NSLog(@"Date1 is in the future"); //升
return 1;
}
else if (result == NSOrderedAscending)
{
//NSLog(@"Date1 is in the past"); //降
return -1;
}
//NSLog(@"Both dates are the same");
return 0;