Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is NSTimeIntervalSince1970 defined as a fixed double?

Just found this in NSDate.h:

#define NSTimeIntervalSince1970  978307200.0

It seems to be the UNIX timestamp of 01.01.2001 00:00:00 GMT.

What is it for and why is it a fixed number?

like image 718
Kai Huppmann Avatar asked Apr 01 '14 09:04

Kai Huppmann


1 Answers

It's because NSDate's timeIntervalSinceReferenceDate uses 1 January 2001, GMT as its reference date while other places typically use 1970 (the "Unix epoch").

It is useful if you want to compare the current time with time stored as an interval since the earlier reference date.

like image 178
Michael Behan Avatar answered Oct 13 '22 00:10

Michael Behan