Search code examples
datepickerswifthour

DatePicker problems in swift


(Sorry for my english)

I made a button to get the value of the DatePicker but the hours in the output is 4 hour late than in the DatePicker

My code:

@IBOutlet var date: UIDatePicker!

@IBAction func sauvegarderClicked(sender: AnyObject) {

    println(date.date)
}

Is this the correct way to get the value from the DatePicker ?

And at the end of the output there is a "+0000" how can i remove this?


Solution

  • The date picker gives you the date in GMT.

    Take a look at NSDateFormatter which will do what you want.