You should be able to use to use NSDateFormatter to format the style of time you want, then read in the string to the formatter and pull it back out in your desired format.
// Get your 24 hr time String format
NSString *timeString = [NSString stringWithFormat:@"%@",[[[arr valueForKey:@"data"] valueForKey:@"pickup_time"] objectAtIndex:indexPath.row]];
//Store your 24 hr time String format into string
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"HH:mm:ss"];
NSDate *time = [dateFormatter dateFromString:timeString];
// Convert time object into desired format
[dateFormatter setDateFormat:@"hh:mm.a"];
cell.lbl_BookingTm.text = [NSString stringWithFormat:@"%@",[dateFormatter stringFromDate:time]]; //Get your string into 12 hr time String format
@python
Hope this helps!
Check out this SO question: NSDateFormatter dateFromString and iPhone in 24 Hour Format Confusion
You should be able to use to use
NSDateFormatter
to format the style of time you want, then read in the string to the formatter and pull it back out in your desired format.Use
NSDateFormatter
to turn the string in aNSDate
. Then use the dateformatter again to change theNSDate
to a string.Code might contain some errors, written without compiling or testing.