Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IOS 6 and NSDateFormatter

Here is the code:

NSString * str = @"2012-11-23Fri09:00:00+0100";

NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
NSLocale *locale= [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
[formatter setLocale:locale];

[formatter setDateFormat:@"yyyy-MM-ddEEEHH:mm:ssZ"];

NSDate *result = [formatter dateFromString:str];
NSLog(@"str :%@ -- NSDate :%@", str, result);

and here is the output:

str :2012-11-23Fri09:00:00+0100 -- NSDate :1999-12-31 08:00:00 +0000

Why the NSDate is wrong?

like image 597
Damien Ferrari Avatar asked Nov 12 '22 16:11

Damien Ferrari


1 Answers

See this Link this might help you,

Formatters in OS X v10.8 and iOS 6.0

Formatters in iOS 5.0-5.1

thanks,

Naveen Shan

like image 108
Naveen Shan Avatar answered Nov 15 '22 06:11

Naveen Shan