75

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?

Moshe
  • 57,511
  • 78
  • 272
  • 425
  • 3
    From [NSTimeInterval reference](http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_DataTypes/Reference/reference.html#//apple_ref/doc/uid/20000018-SW69): Used to specify a time interval, in seconds. `typedef double NSTimeInterval;`. NSTimeInterval is always specified in seconds – albertamg Jul 22 '11 at 22:50

2 Answers2

97

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.

AmitaiB
  • 1,656
  • 1
  • 19
  • 19
esqew
  • 42,425
  • 27
  • 92
  • 132
7

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.

GarlicFries
  • 8,095
  • 5
  • 36
  • 53