In UIDatePicker we can do something like this
datePicker.timeZone = TimeZone(secondsFromGMT: 5*60*60)
in order to specify timezone of datepicker.
But how about doing this in DatePicker in SwiftUI, I cannot find any such param or modifier.
It is possible to do with SwiftUI .environment
modifier as in below example
DatePicker("Due Date", selection: $selected,
displayedComponents: [.date, .hourAndMinute]
)
.environment(\.timeZone, TimeZone(secondsFromGMT: 5*60*60)!)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With