Reputation: 2908
I have tried multiple date formats, but still I get nil back:
Thu May 24 15:51:48 EEST 2012
[formatter setDateFormat:@"E MMM d H:mm:ss z yyyy"];
It is crazy, on my iPhone 3Gs it works, and on a 4S it returns null. They are both set to the same Time Zone.
Maybe the format is wrong, I don't understand what I do wrong.
Thank you.
Upvotes: 1
Views: 112
Reputation: 69499
First of make sure that you set the local of the NSDateFormatter
, else the parsing wil not work on systems where the os language is not set to english.
The reason why it might not parse is because the time is 24 (HH):
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
//Thu May 24 15:51:48 EEST 2012
[dateFormatter setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@"EN"] autorelease]];
[dateFormatter setDateFormat:@"E MMM d HH:mm:ss V yyyy"];
Upvotes: 2