Just to get you started ...
You will create a key date as follows:
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; NSDateComponents *dateComponents = [[NSDateComponents alloc] init]; dateComponents.year = 2012; dateComponents.month = 1; dateComponents.day = 1; dateComponents.hour = 0; dateComponents.minute = 0; dateComponents.second = 0; NSDate *referenceDate = [gregorian dateFromComponents: dateComponents];
The current date can be obtained as follows:
NSDate *now = [NSDate date];
The time interval is in seconds, so ...
NSTimeInterval interval = [now timeIntervalSinceDate:referenceDate]; NSLog (@"reference date was %.0f seconds ago", interval);
I am sure you can understand it here ...
This answer may help you.
Rock jarc
source share