Ali Shahid
Ali Shahid

Reputation: 516

Retrieve date and time from UIDatePicker iOS

I want to retrieve date and time in format e.g "Friday May 31, 2013 12:00 pm". How can I achieve that with NSDateFormatter?

Upvotes: 6

Views: 10485

Answers (1)

Buntylm
Buntylm

Reputation: 7383

NSDate *myDate = datePicker.date;

NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"cccc, MMM d, hh:mm aa"];
NSString *prettyVersion = [dateFormat stringFromDate:myDate];

Upvotes: 22

Related Questions