Calculate the no of days based on year in ios
I will calculate the no of days based on Years.For Ex:If this month is
September,then calculate the no of days (September...December) based on
Current year.And After Jan,It will be calculate based next year.
I retrieve the no of months from Current month upto end of month.
NSDate *curmonth=[NSDate date]; NSString *endmonthstr=@"2013-12-31";
NSDateFormatter *endmonthformatter=[[NSDateFormatter alloc]init];
[endmonthformatter setDateFormat:@"yyyy-MM-dd"];
NSDate *endmonth=[endmonthformatter dateFromString:endmonthstr];
NSInteger month = [[[NSCalendar currentCalendar] components:
NSMonthCalendarUnit
fromDate: curmonth
toDate: endmonth
options: 0] month];
NSInteger monthplus=month+1;
NSInteger count=monthplus;
NSLog(@"%d",monthplus);
But,I dont know how to compare this and calculate the days.
Any idea please help me
No comments:
Post a Comment