首页 > 解决方案 > What is the date formater for this string?

问题描述

I am working in Swift language. I don't know the date format for this 2020-07-23T00:17:06.000Z.

I want to convert Date to String by following that format & vice versa.

How can I do? Thanks in advance...

标签: swiftdate-format

解决方案


it is iso8601

let string = "2020-07-23T00:17:06.000Z"
let dateFormatter = ISO8601DateFormatter()
dateFormatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
let date = dateFormatter.date(from: string)

推荐阅读