1.时间戳(time stamp)
时间戳是指格林威治时间1970年01月01日00时00分00秒(北京时间1970年01月01日08时00分00秒)起至现在的总秒数
let now =NSDate()
let timeInterval:NSTimeInterval = now.timeIntervalSince1970
let timeStamp =Int(timeInterval)
print("当前时间的时间戳:\(timeStamp)")
let dateformatter =NSDateFormatter()
dateformatter.dateFormat ="yyyy年MM月dd日 HH:mm:ss"
print("当前日期时间:\(dateformatter.stringFromDate(now))")
let datefmatter =NSDateFormatter()
datefmatter.dateFormat="yyyy年MM月dd日 HH:mm:ss"
let date = datefmatter.dateFromString("2016年05月15日 00:00:00")
let dateStamp:NSTimeInterval = date!.timeIntervalSince1970
let dateStr:Int =Int(dateStamp)
print(dateStr)//时间转换的时间戳
//时间戳
let timeStamp =1463241600
//转换为时间
let timeInterval:NSTimeInterval =NSTimeInterval(timeStamp)
let date = NSDate(timeIntervalSince1970: timeInterval)
let dateformatter = NSDateFormatter()
dateformatter.dateFormat ="yyyy年MM月dd日 HH:mm:ss" //自定义日期格式
let time = dateformatter.stringFromDate(date)
print("对应时间:"+time)
/*
持续完善更新中...
*/