I had created a Date picker controller and want to set the timeinterval to 12hrs pragmatically.
But i cant do that, i think this is very simple problem but please help me for this.
Thank you in advance.
I had created a Date picker controller and want to set the timeinterval to 12hrs pragmatically.
But i cant do that, i think this is very simple problem but please help me for this.
Thank you in advance.
In Swift 4.X:
let detailsTimeFormatter = DateFormatter()
detailsTimeFormatter.timeStyle = .short
detailsTimeFormatter.dateFormat = "HH:mm"
print(detailsTimeFormatter.string(from: Date()).lowercased())
Assign this time string date to the picker view.
Try this:
NSDateFormatter *detailsTimeFormatter = [[NSDateFormatter alloc] init];
[detailsTimeFormatter setTimeStyle:NSDateFormatterShortStyle];
NSLog(@"%@",[[detailsTimeFormatter stringFromDate:[NSDate date]] lowercaseString]); // this will return you the time with am/pm