Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Navid Mirzaie Milani
6,273 PointsChallange: Using NSDate create a date object that is 10 days from today and call it 'futureDate'.
Im getting the error : Bummer! Your date calculation seems incorrect. Are you using the product of 10 and 'secondsPerDay'?
but when i run the code below in my Xcode the code runs correctly and im getting 27-05-2014 (10 days from today).
NSTimeInterval secondsPerDay = 60 * 60 * 24 * 10; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; // Add your code below
NSDate *today = [[NSDate alloc]init];
NSDate *futureDate = [[NSDate alloc]init]; futureDate = [NSDate dateWithTimeIntervalSinceNow:secondsPerDay];
i don't know what the problem is.
4 Answers

Dave Ko
11,915 PointsNSTimeInterval secondsPerDay = 60 * 60 * 24; // <--- remove the 10 from here
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
// Add your code below
NSDate *today = [[NSDate alloc]init];
NSDate *futureDate = [[NSDate alloc]init];
futureDate = [NSDate dateWithTimeIntervalSinceNow:secondsPerDay * 10]; // <--- add * 10 after seconds var.
See short comments, hope this helps.

Guillaume Maka
Courses Plus Student 10,224 PointsTry this:
NSTimeInterval secondsPerDay = 60 * 60 * 24;
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
// Add your code below
NSDate *today = [NSDate date];
NSDate *futureDate = [NSDate dateWithTimeInterval:secondsPerDay * 10 sinceDate:today];
First time I use the backtick and to find it on French canadian keyboard, just mess

Navid Mirzaie Milani
6,273 PointsTnx Dave Ko ,
Though very strange because i test the above code you gave me also and then it gave me a error ... mm. anyway thank u it worked!

Navid Mirzaie Milani
6,273 Points@Guillaume Maka
aah what a coincidence i just was figuring out how i can manage to calculate the date in the past on base of the current date, thank u very much!