iPhone OS: How do I create an NSDate for a specific date?
@Chuck's answer is correct, and lead me to the following code. Thought I'd share:
NSDateComponents *comps = [[NSDateComponents alloc] init];[comps setDay:10];[comps setMonth:10];[comps setYear:2010];NSDate *date = [[NSCalendar currentCalendar] dateFromComponents:comps];
You can use this
NSString *dateString = @"03-Sep-11";NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];dateFormatter.dateFormat = @"dd-MMM-yy";NSDate *date = [dateFormatter dateFromString:dateString];
Hope this will help you out.
If you're talking about a specific calendar date rather than a UNIXy date, you probably want NSCalendar's dateFromComponents:
.