Closed kavin06 closed 6 years ago
Hey @kavin06 I just tried adding locale to the example project and it seems to be working:
func datePickerTapped() {
var currentDate = Date()
var dateComponents = DateComponents()
dateComponents.month = -3
let threeMonthAgo = Calendar.current.date(byAdding: dateComponents, to: currentDate)
let datePicker = DatePickerDialog(textColor: .red,
buttonColor: .red,
font: UIFont.boldSystemFont(ofSize: 17),
locale: Locale(identifier: "es_PY"), showCancelButton: true)
currentDate.addTimeInterval(-24 * 60 * 60)
datePicker.show("DatePickerDialog",
doneButtonTitle: "Done",
cancelButtonTitle: "Cancel",
defaultDate: currentDate,
minimumDate: threeMonthAgo,
maximumDate: Date(),
datePickerMode: .date) { (date) in
if let dt = date {
let formatter = DateFormatter()
formatter.dateFormat = "MM/dd/yyyy"
self.textField.text = formatter.string(from: dt)
}
}
}
Closing this. Please feel free to reopen if you're still finding problems
I need to change 12 hours format to 24 hours time format,how to add locale in my code and where can you help me pls
let datePicker = DatePickerDialog()
// datePicker.locale: Locale(identifier: "en_GB")
datePicker.show(title: "ON Time", doneButtonTitle: "Done", cancelButtonTitle: "Cancel", defaultDate: defDate, minimumDate: nil, maximumDate: nil, datePickerMode: .time, callback: { (date) -> Void in
if date != nil {
self.cyclicONTimeLabel.text = self.sdf1.string(from: date!)
}
})
Hey @kavin06, please do the following:
let datePicker = DatePickerDialog()
let locale = datePicker.locale: Locale(identifier: "en_GB")
datePicker.show(title: "ON Time", doneButtonTitle: "Done", cancelButtonTitle: "Cancel", defaultDate: defDate, minimumDate: nil, maximumDate: nil, datePickerMode: .time, locale: locale, callback: { (date) -> Void in
if let selectedDate = date {
self.cyclicONTimeLabel.text = self.sdf1.string(from: selectedDate)
}
})
How to change the localy in xcode 8
DatePickerDialog(locale: Locale(identifier: "es_PY")) is not working