Show Time in 12 and 24 hour format in UIDatepicker on the basis of app settings not on device Settings Show Time in 12 and 24 hour format in UIDatepicker on the basis of app settings not on device Settings ios ios

Show Time in 12 and 24 hour format in UIDatepicker on the basis of app settings not on device Settings


Try this code to show 24 Hrs Format in DatePicker:

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


In Swift

    // myDatePicker is yourUIDatePicker Outlet    @IBOutlet weak var myDatePicker: UIDatePicker!    // For 24 Hrs     myDatePicker.locale = NSLocale(localeIdentifier: "en_GB") as Locale    //For 12 Hrs    timePickerView.locale = NSLocale(localeIdentifier: "en_US") as Locale


For UIDatePicker you cannot change the time format to 24 or 12, it depends on the user local settings in setting.app


matomo