Вопрос

I execute following snippet of code:

NSCalendar *gregorian = [[NSCalendar alloc]initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *comp = [gregorian components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:[NSDate date]]; 
[comp setDay:1]; 

NSDate *firstDayOfMonthDate = [gregorian dateFromComponents:comp];

The Value of firstDayOfMonthDate is = 30-4-2011 but excpeted is 1-5-2011 i.e I want first date of month of any specified date. But it gives me the last date of the previous month.

thanks in advance.

Нет правильного решения

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top