標(biāo)準(zhǔn)格式時(shí)間字符串轉(zhuǎn)時(shí)間戳:
? ? ? ? ? ? ? ? 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
時(shí)間戳字符串轉(zhuǎn)時(shí)間:
???????????? ?? ? ? let timeStr = "\(item.beginTime)" as NSString //beginTime為時(shí)間戳字符串
??????????????????? let timeInt:TimeInterval = timeStr.doubleValue
??????????????????? let date = Date(timeIntervalSince1970: timeInt/1000)
?????????????????? ?? let dfmatter = DateFormatter()
?????? ? ? ? ? ? ? ?? dfmatter.dateFormat="yyyy年MM月dd日 hh:mm:ss"
???? ? ? ? ? ? ? ?? ? print("時(shí)間 = \(dfmatter.string(from: date))")