2

I am able to display the calendar (dates) of this month in table view and I am highlighting the current date and it is working fine, but now what I want to do is to display next coming 2 weeks from the current date.

I am using the following code to get the dates of the month

NSDate *today = [NSDate date]; 
NSCalendar *calender = [NSCalendar currentCalendar];
days = [calender rangeOfUnit:NSDayCalendarUnit 
                      inUnit:NSMonthCalendarUnit 
                     forDate:today];

How to calculate the up coming two weeks from today?

Francois
  • 10,730
  • 7
  • 47
  • 80
user564963
  • 2,284
  • 5
  • 24
  • 33
  • possible duplicate of [Obtain yesterday with NSDate in objective-c](http://stackoverflow.com/questions/8135382/obtain-yesterday-with-nsdate-in-objective-c) – progrmr Nov 24 '11 at 14:24

2 Answers2

2

Check my answer from this post. There you can set value for daysToAdd that you want and get the NSDate corresponding.

Community
  • 1
  • 1
Ilanchezhian
  • 17,426
  • 1
  • 53
  • 55
0

May be you can try with:

NSDate *inTwoWeeks = [NSDate dateWithTimeIntervalSinceNow:60*60*24*7*2]

Francois
  • 10,730
  • 7
  • 47
  • 80
  • 2
    Best to use `NSCalendar` method: `- (NSDate *)dateByAddingComponents:(NSDateComponents *)comps toDate:(NSDate *)date options:(NSUInteger)opts`, it handles the corner cases. – zaph Nov 24 '11 at 13:53