DatePicker in SwiftUI allows users to view a scrolling wheel to pick a date and time. Like most UI controls, it can be customised greatly. In terms of function, its similar to the UIDatePicker from the UIKit.
Like most controls, it needs to have a binding variable to store its value.
DatePicker("< String label", selection: $< name of binding variable >,
displayedComponents: .date)
Or,
DatePicker("< String label", selection: $< name of binding variable >,
displayedComponents:[ .date, .hourandMinute])