Your dateFormat does not match the format of your date string. Read about the Unicode Date Format Patterns.
And after that try @"yyyy-MM-dd'T'HH:mm:ssZZZ"
But I think you try to do something wrong anyway.
A NSDate is a point in time, it is the same for every place in the world. You don't need to calculate a new NSDate just because your source is in a different timezone.
Use the dateFormat from above and compare it directly to a different NSDate.
Probably something like this:
NSString *serverTime = @"2012-01-11T06:17:39+0000";
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZZZ"];
NSDate* sourceDate = [dateFormatter dateFromString:serverTime];
if (!sourceDate) {
NSLog(@"Wrong NSDateFormatter format!");
}
else {
NSDate *date24HoursAgo = [NSDate dateWithTimeIntervalSinceNow:-(24*60*60)];
NSLog(@"%@", sourceDate);
NSLog(@"%@", date24HoursAgo);
if ([sourceDate compare:date24HoursAgo] == NSOrderedAscending) {
NSLog(@"Timestamp from server is older than 24 hours.");
}
}