Convert NSString of a date to an NSDate

NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"MM/dd/yyyy h:mm a"];
NSDate *date = [dateFormat dateFromString:dateStr];
[dateFormat release];

there is no problem in 2 digit day or 2 digit month.

This must help you.

Leave a Comment