标准格式时间字符串转时间戳:
let dfmatter = DateFormatter()
dfmatter.dateFormat="YYYY/MM/dd hh:mm:ss"
let date = dfmatter.date(from: "2017/12/05 09:52:00")
let timeInt = date?.timeIntervalSince1970
时间戳字符串转时间:
let timeStr = "\(item.beginTime)" as NSString //beginTime为时间戳字符串
let timeInt:TimeInterval = timeStr.doubleValue
let date = Date(timeIntervalSince1970: timeInt/1000)
let dfmatter = DateFormatter()
dfmatter.dateFormat="yyyy年MM月dd日 hh:mm:ss"
print("时间 = \(dfmatter.string(from: date))")