[英]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. 在Swift 2.3中,我编写了一个函数,该函数的日期为6-01-16,将其转换为NSDate,然后在CKQuery中使用它。 I'm not sure how to update this for Swift 3.
我不确定如何为Swift 3更新它。
Here's my current code: 这是我当前的代码:
let formatter = DateFormatter()
formatter.dateFormat = "yyyymmdd"
let olddate = formatter.date(from: "20160601")
print(olddate)
This isn't working, how should I change my syntax? 这不起作用,应该如何更改语法?
mm
is the format for minutes; mm
是分钟的格式; you mean MM
for months. 你的意思是
MM
几个月。 Your dateFormat
should be: 您的
dateFormat
应该是:
"yyyyMMdd"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.