tags:

views:

56

answers:

1

I need help on how to find out how many days it has been (seven day weeks, MSTimezone) since May 6th, 2009

[NSDate *m62009 = [NSDate dateWithTimeIntervalSinceReferenceDate:231638400]; [m62009 setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"MST"]; (to help you - 231638400 seconds from 1/1/2001)


Edit:
And then how can I convert the NSTimeInterval into days as an integer or string

+1  A: 

This has been covered here, but the solution you're looking for should be something like the following:

NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];

NSDate *date1 = [dateFormatter dateFromString:@"2009-05-06"];
NSDate *date2 = [NSDate date]; // Should produce today's date

NSTimeInterval diff = [date2 timeIntervalSinceDate:date1]

You can then format the NSTimeInterval as you see fit.

KushalP