My date string that I am getting is 8/5/2011 1:38:13 PM of this format. How do I convert it to NSDate?
I tried:
[dateFormatter setDateFormat:@"mm/dd/yyyy 'T' hh:mm:ss a"];
NSString *currentDate = [dateFormatter stringFromDate:currentDateString];
It returns nil. Any thoughts?
The reason it returns nil is because you are calling the wrong method, there is no
Tin your date string (characters inside of single quotes'in are literals), and the PM is not “P.M.”. Things that are not breaking it but are not completely correct is you are trying to parse the month as a minute and your date string can have a minimum of 1 digit month, day, and hour so you should not use 2 specifiers which would pad them if you were to create a string from the date. Try this: