Below is what I am using
NSString *myDate = @"01-11-2014 10:22 PM";
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"dd-MM-yyyy hh:mm a"];
NSDate *newDate = [dateFormatter dateFromString:myDate];
NSLog(@"new date===%@=====%@", newDate, myDate);
Below is what I am getting
new date===2014-11-01 19:22:00 +0000=====01-11-2014 10:22 PM
^^
Output I was expecting is
new date===2014-11-01 22:22:00 +0000=====01-11-2014 10:22 PM
^^
Any idea what is going wrong?
When I have AM I have below output
new date===2014-11-01 07:22:00 +0000=====01-11-2014 10:22 AM
^^
Edit 1
Actually what I am doing is asked date and time in UITextField (sadly but true as client wanted it in same way)... and then concatenating this string and converting it to NSDate.
So what I have is
NSString myDate = [NSString stringWithFormat@"%@ %@", appDate, appTime];