Reputation:
I m using date picker in my project and I m getting selected date as 24 hour format after applying format attribute as hh:mm . I can get 12 hour format date from by converting it using conditions but I want to know some direct method to get 12 hour format time from date picker with AM , PM . If anybody knows shortest way to do it then please indicate me by your answer. Thank you!
Upvotes: 0
Views: 6425
Reputation: 12641
I have made a method for this , try it
-(NSString*)getTimetoFill
{
NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init];
[outputFormatter setDateFormat:@"h:mm a"];
NSString *timetofill = [outputFormatter stringFromDate:datepicker.date];
return timetofill;
}
Upvotes: 5