妳知道我在等妳嗎? 妳如果真的在乎我。感謝Apple真的在乎我們,聽到我們的心聲。在iOS 10,iOS SDK終於內建 ISO8601 !

例1: String轉Date,方便我們將後台回傳的ISO8601格式字串轉成Date。

let dateFormatter = ISO8601DateFormatter()
let date = dateFormatter.date(from: “1983–02–07T02:15:30Z”)

例2: Date轉String,方便我們將Date轉成ISO8601格式上傳後台。

let dateFormatter = ISO8601DateFormatter()
let today = Date()
let date = dateFormatter.string(from: today)

補充:

彼得潘的iOS App程式設計入門,文組生的iOS App程式設計入門講師,彼得潘的 Swift 程式設計入門,App程式設計入門作者,http://apppeterpan.strikingly.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store