[英]where is timeIntervalSince1970 property in swift
I am trying to get the current milliseconds and according to all the questions on Google, i should use timeIntervalSince1970 property of NSDate 我正在尝试获取当前毫秒,并根据Google上的所有问题,我应该使用NSDate的timeIntervalSince1970属性
however i already did this: 但是我已经做到了:
var startTime = NSData()
and then
startTime. timeIntervalSince1970
and
startTime. timeIntervalSince1970()
but it seems there is no property anymore, right? 但似乎已经没有财产了,对吗?
if yes, what is the replacement please? 如果是,请更换什么?
The error is: NSDate
not NSData
. 错误是:
NSDate
不是NSData
。
Also there should not be space after the "."? 还应该在“。”之后没有空格吗?
var startTime = NSDate() let interval = startTime.timeIntervalSince1970 var startTime = NSDate()let interval = startTime.timeIntervalSince1970
From Apple docs: 从苹果文档:
var timeIntervalSince1970: NSTimeInterval { get }
This property's value is negative if the date object is earlier than January 1, 1970 at 12:00 am GMT.
如果日期对象早于格林尼治标准时间1970年1月1日上午12:00,则此属性的值为负。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.