1.时间转时间戳函数
<code>
/**
时间转化为时间戳
:param: stringTime 时间为stirng
:returns: 返回时间戳为stirng
*/
static func stringToTimeStamp(stringTime:String)->String {
var dfmatter = NSDateFormatter()
dfmatter.dateFormat="yyyy年MM月dd日"
var date = dfmatter.dateFromString(stringTime)
var dateStamp:NSTimeInterval = date!.timeIntervalSince1970
var dateSt:Int = Int(dateStamp)
print(dateSt)
return String(dateSt)
}
</code>
2. 时间戳转时间函数
<code>
/**
时间戳转时间
:param: timeStamp <#timeStamp description#>
:returns: return time
*/
static func timeStampToString(timeStamp:String)->String {
var string = NSString(string: timeStamp)
var timeSta:NSTimeInterval = string.doubleValue
var dfmatter = NSDateFormatter()
dfmatter.dateFormat="yyyy年MM月dd日"
var date = NSDate(timeIntervalSince1970: timeSta)
print(dfmatter.stringFromDate(date))
return dfmatter.stringFromDate(date)
}
</code>