What is NSDateFormatter string for the following date / time: 02/22/2011 10:43:00 AM
Basically I wanted to read line 02/22/2011 19:00:23 PM , convert it to NSDate , and then print accordingly. My previous attempt:
NSDateFormatter* dtFormatter = [[NSDateFormatter alloc] init]; [dtFormatter setDateFormat:@"MM/dd/yyyy HH:mm:ss a"]; NSDate* dt3 = [dtFormatter dateFromString:@"02/22/2011 19:00:23 PM"]; NSString* strDate3 = [dtFormatter stringFromDate:dt3]; NSLog(@"Third = %@",strDate3);
Every time I tried for it to print NULL, it worked when I deleted the final PM.
Finally, I added the following lines immediately after the second line in the code above:
[dtFormatter setPMSymbol:@"PM"]; [dtFormatter setAMSymbol:@"AM"];
source share