相关疑难解决方法(0)

Swift中的日期格式

我如何从日期转换此日期时间?

由此:2016-02-29 12:24:26发布
于:2016年2月29日

到目前为止,这是我的代码,它返回一个nil值:

let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "MM-dd-yyyy"
dateFormatter.timeZone = NSTimeZone(name: "UTC")
let date: NSDate? = dateFormatter.dateFromString("2016-02-29 12:24:26")
print(date)
Run Code Online (Sandbox Code Playgroud)

nsdate nsdateformatter ios swift

115
推荐指数
15
解决办法
19万
查看次数

标签 统计

ios ×1

nsdate ×1

nsdateformatter ×1

swift ×1