DatePicker correct date with only date extracted

69 Views Asked by At

the below post answered half of my question, but I still need to extract only the date without the time of the corrected date, would you kindly help me guys: xcode in swift datepicker picks wrong date

1

There are 1 best solutions below

0
nasser On

I could finally find a function that combines using locale time and getting the short format of the date only. below is what I used.

    @IBAction func DateChanged(sender: UIDatePicker) {



    let dateFormatter = NSDateFormatter.localizedStringFromDate(DatePicker.date, dateStyle: NSDateFormatterStyle.ShortStyle, timeStyle: .NoStyle)



    print(" Date: " + dateFormatter)

}