//返回当前时间的时间戳
class func YhyGetTimeCHUO() -> Int{
//获取当前时间
let now = NSDate()
// 创建一个日期格式器
let dformatter = DateFormatter()
dformatter.dateFormat = "yyyy年MM月dd日 HH:mm:ss"
print("当前日期时间:\(dformatter.string(from: now as Date))")
//当前时间的时间戳
let timeInterval:TimeInterval = now.timeIntervalSince1970
let timeStamp = Int(timeInterval)
return timeStamp
}
网友评论