/**
根据时间获得时间戳 13位
:param: dateStr 要转换的时间
:returns: 时间戳
*/
@objc class func getTimestampWithTime(_ dateStr: NSString) -> NSString
{
var strTime: NSString?
if dateStr.length > 19
{
strTime = dateStr.substring(to: 19) as NSString?
}
else
{
strTime = dateStr
}
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
let date: Date = formatter.date(from: strTime! as String)!
// println(date)
let t = date.timeIntervalSince1970 * 1000
// println(t)
var timestamp: NSString = "\(t)" as NSString
timestamp = timestamp.substring(to: timestamp.length - 2) as NSString
// println(timestamp)
return timestamp
}
网友评论