RakeshDipuna RakeshDipuna - 28 days ago 6
Swift Question

How can I change NSDate to a date string picked from date picker?

UIDatePicker returns me the date in the form of 15Aug,2016 but my date format should be 15/08/2016 in string format.
Example "dob" = "15/08/2016"
I am using this code

let dateFormatter=NSDateFormatter()
let strDate=dateFormatter.stringFromDate(myDatePicker.date) as String
dict["dob"] = strDate

But I am not getting proper string .

Ram Ram

you can use this

 let dateformatter = NSDateFormatter()

    dateformatter.dateStyle = NSDateFormatterStyle.ShortStyle

    let dob = dateformatter.stringFromDate(NSDate())

the dob in 15/08/2016 formet