[Solved] NSDateFormatter not working [closed]


You need two formats. One to parse the original string. The second to generate the desired output. You are trying to parse the string with the output format. That won’t work.

NSDateFormatter *formatterObj = [[NSDateFormatter alloc]init];

[formatterObj setDateFormat:@"yyyy-MM-dd HH:mm:ss ZZZ"];
NSDate *newDate = [formatterObj dateFromString:@"2013-03-04 19:12:55 +0000"];
[formatterObj setDateFormat:@"MMM dd, yyyy"];
NSString *stringDate = [formatterObj stringFromDate:newDate];

NSLog(@"%@",stringDate);

1

solved NSDateFormatter not working [closed]