user2384583 user2384583 - 1 year ago 158
Objective-C Question

Is there anyway to hide the 24hrs format in UIDatePicker

I am doing the application with

for time format. It is working in 12hrs format, if i change the iPhone date/time to 24hrs format, I need to display only 12hrs format, not the 24hrs format.

Is there anyway to disable the 24hrs format?

Answer Source

Use this code for 12 hour format

NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"US"];
[self.datePicker setLocale:locale];

Use this code for 24 hour format

NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:@"NL"];
[self.datePicker setLocale:locale];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download