美文网首页
Swift 获取系统时间

Swift 获取系统时间

作者: Str1ng | 来源:发表于2017-03-17 11:13 被阅读0次

项目中经常需要获取特定格式的系统时间,可使用以下方法

static func getDateTime() -> String{

var date = Date.init()

var timeFormatter = DateFormatter.init()

timeFormatter.dateFormat="yyyyMMddHHmmss"

return timeFormatter.string(from: date)

}

相关文章

网友评论

      本文标题:Swift 获取系统时间

      本文链接:https://www.haomeiwen.com/subject/cxhenttx.html