Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What unit of time does timeIntervalSinceDate return?

What unit of time does timeIntervalSinceDate return? Is it seconds, milliseconds or something else?

The documentation says that it returns an NSTimeInterval, but what unit of time is that value?

like image 757
Moshe Avatar asked Jul 22 '11 22:07

Moshe


2 Answers

It returns the number of seconds, as an NSTimeInterval value.

From this documentation page:

NSTimeInterval is always specified in seconds; it yields sub-millisecond precision over a range of 10,000 years.

like image 56
esqew Avatar answered Oct 21 '22 12:10

esqew


Well the NSDate docs show the function prototype as:

- (NSTimeInterval)timeIntervalSinceDate:(NSDate *)anotherDate

And the Foundation Data Types doc states:

NSTimeInterval is always specified in seconds; it yields sub-millisecond precision over a range of 10,000 years.

like image 7
GarlicFries Avatar answered Oct 21 '22 12:10

GarlicFries