获取当前月第一天是星期几

1第一种方法

NSDate*currentdate=[NSDatedate];

intfirstDayOfMonthInt=[[NSCalendarcurrentCalendar]ordinalityOfUnit:NSCalendarUnitDayinUnit:NSCalendarUnitWeekOfMonthforDate:currentdate];

2第二种方法

NSCalendar*calendar=[[NSCalendaralloc]initWithCalendarIdentifier:NSCalendarIdentifierGregorian];

NSDateComponents*comps = [calendarcomponents:NSCalendarUnitWeekdayfromDate:[NSDatedate]];

NSIntegerweekday = [compsweekday];

你可能感兴趣的:(获取当前月第一天是星期几)