I want to find number of day today is in current year. e.g, if today is Mar15, 2012 I should get 75(31 + 29 + 15). Or we can simply say that number of days between today and
Using NSDateComponents
you can can gather the NSDayCalendarUnit
component which should indicate the current day of the year.
Something along the lines of the following should suit your needs:
//create calendar
NSCalendar *calendar = [NSCalendar currentCalendar];
//set calendar time zone
[calendar setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];
//gather date components
NSDateComponents *components = [calendar components:NSDayCalendarUnit fromDate:[NSDate date]];
//gather time components
NSInteger day = [components day];