私はこのように2つの日付を比較しています:
NSDateFormatter *df= [[NSDateFormatter alloc] init];
[df setDateFormat:@" dd : MM : yyyy"];
NSDate *dt1 = [[NSDate alloc] init];
dt1=[df dateFromString:TheDate];
NSDate *Date=[NSDate date];
NSLog (@"DATE CURRENT: %@ DATE 2 %@", Date, dt1);
if ([Date compare:dt1] == NSOrderedDescending) {
NSLog(@"Date is later than date2");
} else if ([Date compare:dt1] == NSOrderedAscending) {
NSLog(@"Date is earlier than date2");
[postsToBeDeleted addObject: textmessage];
} else {
NSLog(@"dates are the same");
}
NSLogは私に:
DATE CURRENT: 2013-02-05 21:37:54 +0000 DATE 2 2012-01-04 23:00:00 +0000
しかし、現在の日付がdt1の日付よりはるかに進んでいることは明らかですが、それでもNSLog(@ "Date is later than date2");を取得します。どうしてこれなの?