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.
More Related Contents:
- NSDate Format outputting wrong date
- How to parse a date string into an NSDate object in iOS?
- How do you calculate the day of the year for a specific date in Objective-C?
- NSDateFormatter, am I doing something wrong or is this a bug?
- Why NSDateFormatter can not parse date from ISO 8601 format [duplicate]
- NSDateFormatter and yyyy-MM-dd
- NSDateFormatter and Time Zone issue?
- How to compare two NSDates: Which is more recent?
- Comparing two NSDates and ignoring the time component
- Ordinal Month-day Suffix Option for NSDateFormatter setDateFormat
- How Do I write a Timer in Objective-C?
- How to change the format of date in date picker
- Objective-C setting NSDate to current UTC
- Difference between two NSDate objects — Result also a NSDate
- Removing time components from an NSDate object using Objective C/Cocoa
- How to Get time difference in iPhone
- UIDatePicker, setting maximum and minimum dates based on todays date
- Formatting date and time with iPhone SDK?
- Difference between self.ivar and ivar?
- Understanding reference counting with Cocoa and Objective-C
- Detect the specific iPhone/iPod touch model [duplicate]
- Objective-c iPhone percent encode a string?
- How do I add a gradient to the text of a UILabel, but not the background?
- Just two rounded corners? [duplicate]
- Keeping object on top of keyboard in the event of becomeFirstResponder or resignFirstResponder?
- Convert milliseconds to NSDate
- Core-Data iPhone: could not locate an NSManagedObjectModel
- Finding Path/Route Between two points on MapKit in iPhone
- Moving status bar in iOS 7
- (iphone) UIImageView setImage: leaks?