Alex Alex - 1 year ago 196
iOS Question

Swift 3 How to create Date for a specific date

In swift 2.3, I wrote a function that takes the date 6-01-16, converts it to NSDate, then utilizes that in a CKQuery. I'm not sure how to update this for Swift 3.

Here's my current code:

let formatter = DateFormatter()
formatter.dateFormat = "yyyymmdd"
let olddate = "20160601")

This isn't working, how should I change my syntax?

Answer Source

mm is the format for minutes; you mean MM for months. Your dateFormat should be:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download