swift - 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...
解决方案
it is iso8601
let string = "2020-07-23T00:17:06.000Z"
let dateFormatter = ISO8601DateFormatter()
dateFormatter.formatOptions = [.withInternetDateTime, .withFractionalSeconds]
let date = dateFormatter.date(from: string)
推荐阅读
- android - Android studio gradle 脚本找不到 Pattern 类
- c - 冲突的函数声明和宏?
- android - Android 使用什么来禁止在后台启动服务?
- python - Django - 限制选择以选择管理表单中未选择的内容
- python - Django视图仅将主键从字段返回到模板,没有数据
- c# - 在字符串中的特定单词之后只取 9 个字符
- javascript - 是否可以指示浏览器在异步 DOM 操作期间不要渲染/重排/更新视口?
- php - 多对一关系中的继承实体
- c++ - 使用 clang 格式的 'BreakConstructorInitializers: AfterColon'
- javascript - javascript 的 onclick 函数中未解析的 div 数组