//时间转字符串
let date =Date()
let dfmatter =DateFormatter()
dfmatter.dateFormat="yyyy-MM-dd HH:mm:ss"
let dateStr = dfmatter.string(from: date)
//时间转时间戳
let timestamp = date.timeIntervalSince1970
//字符串转时间
let dateNew = dfmatter.date(from: dateStr)
//时间戳转时间
let dateNew2 =Date.init(timeIntervalSince1970: timestamp)
网友评论