Swift ios date as milliseconds Double or UInt64?
Swift does not allow comparing different types.
seconds
is a Double
floating point value in seconds with sub-second accuracy.sampleDate
is a UInt64 but the units are not given.
sampleDate
needs be converted to a Double
floating point value with units of seconds.
var sampleDate: Double = Double(sample.getStartDate())
Then they can be compared:
if(sampleDate > cuttDate){}
in iOS it is better to use double, but if you want to easy port your code and keep it consistent you can try this:
func currentTimeMillis() -> Int64{
let nowDouble = NSDate().timeIntervalSince1970
return Int64(nowDouble*1000)
}