I tried this:
NSDateFormatter *df= [[[NSDateFormatter alloc] init] autorelease];
[df setDateFormat:@"yyyy-MM-dd HH:MM:SS"];
NSDate *dt2 = [df dateFromString:@"2011-11-23 09:44:12"];
But when I do:
NSLog(@"dt2 is %@", dt2);
it returns null.Any idea why?
Try this code:
Here in
HH:mm:ss, you had usedMMfor minutes instead ofmmandSSfor seconds in place ofss. That was the mistake you committedHope this helps you.