【问题标题】:How to convert sql timestamp to date in swift? [duplicate]如何快速将sql时间戳转换为日期? [复制]
【发布时间】:2016-10-11 05:44:48
【问题描述】:

我从数据库 SQL 查询(如 1465536311 或 1465540078)获得时间戳结果。如何快速将此类数字转换为当前日期和时间?

【问题讨论】:

标签: ios sql swift datetime timestamp


【解决方案1】:

来自 NSDateFormatter Class Reference :

let date = NSDate(timeIntervalSince1970: 1465536311)

【讨论】:

  • 感谢您的简洁回答。顺便说一句,我只能在 NSDate 类参考中找到 timeIntervalSince1970 参考。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-11-29
  • 2019-09-06
  • 2017-12-12
  • 1970-01-01
  • 2018-01-06
  • 2016-05-17
相关资源
最近更新 更多