I'm trying to get the time in milliseconds since a certain date. Here is my code:
startTime = NSDate.timeIntervalSinceReferenceDate()
startDate = NSDate()
let dateComponents = NSCalendar.currentCalendar().components(NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitMinute | NSCalendarUnit.CalendarUnitSecond | NSCalendarUnit.CalendarUnitNanosecond, fromDate: startDate, toDate: NSDate(), options: nil)
println("\(dateComponents.seconds)")
(I did seconds to make it easier, but in the actual thing I will need milliseconds.) It gives me seconds, but after 59, it goes back to 0. (It's a timer. If you want I can show that code too, but I thought it wouldn't be necessary.)
How can I get it to show milliseconds and go all the way - I don't want it to start over?
Update
I tried the following:
let milliseconds : Double = [startDate .timeIntervalSinceNow] * -1000.0
It then says to put a comma after startDate
. After I do that, I get an error:
Could not find member
'timeIntervalSinceNow'