Reputation: 294
I'm trying to format an NSDate out of a date given by the Twitter api (JSON). I'm using a NSDateFormatter therefore.
NSString *dateString = string;
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
//[dateFormat setDateFormat: @"EEE dd MMM yyyy HH:mm:ss Z"];
NSDate *date = [dateFormat dateFromString:dateString];
NSLog(@"%@",date);
return date;
But, this returns null. The date the Twitter API is giving me is looking like this: Thu, 19 Jan 2012 07:04:51 +0000.
Does anyone have a solution for this problem?
Thanks!
Upvotes: 0
Views: 922
Reputation:
You missed the comma following the day in your format string. Correctly:
[dateFormat setDateFormat: @"EEE, dd MMM yyyy HH:mm:ss Z"];
Upvotes: 3