squimer / DatePickerDialog-iOS-Swift

Date picker dialog for iOS
MIT License
581 stars 177 forks source link

24H format? #39

Closed flaviusdemian closed 7 years ago

flaviusdemian commented 7 years ago

Hello,

Can you please point out how to enable 24H format instead of using AM and PM for the time?

Thank you.

lfarah commented 7 years ago

Hey @slown1, DatePickerDialog has a datePicker: UIDatePicker, so you can select the 24H mode by doing the following:

        let dialog = DatePickerDialog()
        dialog.datePicker.datePickerMode = UIDatePickerMode.time
        dialog.datePicker.locale = NSLocale(localeIdentifier: "en_GB") as Locale // using Great Britain for this example

        dialog.show(title: "DatePickerDialog", doneButtonTitle: "Done", cancelButtonTitle: "Cancel", minimumDate: threeMonthAgo, maximumDate: currentDate, datePickerMode: .dateAndTime) { (date) in
            if let dt = date {
                self.textField.text = "\(dt)"
            }
        }

Let me know if you need additional help 👍

kavin06 commented 6 years ago

Thankyou so much...its working

kavin06 commented 6 years ago

Hello, In my project i need up to 99 hours time format.how to change 24 hours to 99 hours..Can you help me

lfarah commented 6 years ago

@kavin06 unfortunately you won't be able to do that since UIDatePicker doesn't support that