let timestampInt64 = 1449805150184func parseDateFromTimestamp(timestampValue:Int) -> NSDate { let parsedDate:NSDate = NSDate( return parsedDate } |
搜:
swift timestamp to date
ios – Convert timestamp into NSDate swift? – Stack Overflow
Swift convert unix time to date and time – Stack Overflow
【总结】
import UIKitlet timestampIntInMsec = 1449805150184func parseDateFromTimestamp(timestampIntInMsec:Int) -> NSDate { print("timestampIntInMsec=\(timestampIntInMsec)") let timestampDoubleInSec:Double = Double(timestampIntInMsec)/1000 print("timestampDoubleInSec=\(timestampDoubleInSec)") let parsedDate:NSDate = NSDate(timeIntervalSince1970: NSTimeInterval(timestampDoubleInSec)) print("parsedDate=\(parsedDate)") return parsedDate } parseDateFromTimestamp(timestampIntInMsec) |
输出:
timestampIntInMsec=1449805150184 timestampDoubleInSec=1449805150.184 parsedDate=2015-12-11 03:39:10 +0000 |
转载请注明:在路上 » [已解决]swift时间戳转换为日期时间