I got a string that contains the current date by using this :
NSString *date = [[NSDate date] description];
At a different point I am want to retrieve the date from this string and I use the following code
[NSDateFormatter setDefaultFormatterBehavior:NSDateFormatterBehavior10_4];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
//[NSDateFormatter setDefaultFormatterBehavior:NSDateFormatterBehaviorDefault];
[dateFormatter setDateFormat:@"YYYY-MM-DD HH:MM:SS ±HHMM"];
NSDate *dateFromString = [[NSDate alloc] init];
dateFromString = [dateFormatter dateFromString:<NSString containing date>];
I am getting 'dateFromString' as nil 0x0. What I am doing wrong?