Show DatePicker hourAndMinute on print statement SwiftUI

后端 未结 1 1896
我寻月下人不归
我寻月下人不归 2021-01-29 07:50

I have the following DatePicker:

Section(header: Text(\"Notifications will be triggered only between \\(startDay) and \\(endDay)\")) {
                    DatePi         


        
相关标签:
1条回答
  • 2021-01-29 08:33

    Use DateFormatter, for example something like:

    var dateFormatter: DateFormatter {
        let formatter = DateFormatter()
        formatter.dateFormat = "HH:mm"
        return formatter
    }
    
    Section(header: Text("Notifications will be triggered only between \(dateFormatter.string(from: startDay)) and \(dateFormatter.string(from: endDay))")) {
                    DatePicker("Start day", selection: $startDay, displayedComponents: .hourAndMinute)
                    DatePicker("End day", selection: $endDay, displayedComponents: .hourAndMinute)
                }
    
    0 讨论(0)
提交回复
热议问题