【问题标题】:I want to convert current Date to simple Date format [duplicate]我想将当前日期转换为简单的日期格式 [重复]
【发布时间】:2018-01-02 17:15:00
【问题描述】:

谁能帮我把当前日期转换成这种格式:

“2017-06-15T05:15:31.158Z”。

我只需要这种格式,我的后端不接受其他格式。

朋友,请帮帮我。

【问题讨论】:

  • 始终显示您尝试过的代码

标签: ios nsdateformatter


【解决方案1】:

试试这个

let formatter = NSDateFormatter()
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
let timeString = formatter.stringFromDate(NSDate())
print(timeString) 

How to get yyyy-mm-dd hh:mm:ss format from "2015-06-26T00:10:00+01:00" in swift

【讨论】:

  • 嗨 junaid....我试过了,但它正在打印“2017-07-27 12:18:41”....T 和 Z 不见了
猜你喜欢
  • 2014-05-30
  • 1970-01-01
  • 1970-01-01
  • 2018-09-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-02-12
相关资源
最近更新 更多