Getting readable time from timeIntervalSinceDate in fast

I am trying to figure out how to get a readable amount of time from timeIntervalSinceDate. Right now I have an NSDate with the key "punchInTime" stored in NSUserDefaults, but I do not know how to get the read time back when I want to find the difference between the saved NSDate "punchInTime" and the current time. I have:

var totalWorkTime = NSDate.timeIntervalSinceDate(punchInTime)

I would like to interpolate "totalWorkTime" into a string to have available time values.

Any help appreciated! Thank.

+4
source share
1 answer

Correct your syntax. It should be:

var totalWorkTime = NSDate().timeIntervalSinceDate(punchInTime)

NSDate. totalWorkTime NSTimeInterval, Cannot invoke [operator] with an argument list of type ...

enter image description here

, . (x) -> y is not convertible to y

enter image description here

Swift - . NSDate, totalWorkTime NSTimeInterval, , NSDate NSTimeInterval. :

enter image description here

, , zisoft (), . , Double (NSTimeInterval), Int.

+7

All Articles