1

I am trying to do this in Xcode...

Today's Date = Day of the year

October 13th = 303 (I think) January 1st = 1 December 31st = 365

NSDate to get todays date, then I'm out of idea =(

slowman21
  • 2,505
  • 3
  • 20
  • 20
  • 1
    Possible dupe of this http://stackoverflow.com/questions/2080927/how-do-you-calculate-the-day-of-the-year-for-a-specific-date-in-objective-c – aegzorz Oct 13 '10 at 16:44

2 Answers2

2

See the documentation for NSCalendar and NSDateComponents

Nimrod
  • 5,168
  • 1
  • 25
  • 39
2
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"D"];
NSDate *date = [NSDate date];

NSLog(@"Today: %@", date);
NSLog(@"Date Formatted: %@", [dateFormatter stringFromDate:date]);

[dateFormatter release];
slowman21
  • 2,505
  • 3
  • 20
  • 20