如何将此 UNIX 纪元日期(以毫秒为单位)转换为本地日期/时间? [英] How to convert this UNIX epoch date in milliseconds to local date/time?
本文介绍了如何将此 UNIX 纪元日期(以毫秒为单位)转换为本地日期/时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从服务器收到一些奇怪的日期/时间.
I am getting something strange date/time from server.
如何转换"notification_date": 1500461137000,到本地时间格式.
How to convert "notification_date": 1500461137000, to local time format.
推荐答案
这是一个以毫秒为单位的 UNIX 纪元日期.可以用timeIntervalSince1970
除以1000后进行转换.
This is a UNIX epoch date in milliseconds. You can convert it with timeIntervalSince1970
after dividing it by 1000.
let localDate = Date(timeIntervalSince1970: notificationDate / 1000)
这篇关于如何将此 UNIX 纪元日期(以毫秒为单位)转换为本地日期/时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文