获取本周是这月的第几周

NSDate *currentDate = [NSDate date];//获取当前时间,日期
NSDateFormatter dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"YYYY年MM月"];
NSString dateString = [dateFormatter stringFromDate:currentDate];
NSCalendar
calendar = [NSCalendar currentCalendar];
NSDateComponents
comps;
comps = [calendar components:NSCalendarUnitWeekdayOrdinal|NSCalendarUnitMonth|NSCalendarUnitWeekday fromDate:currentDate];

NSInteger weekdayOrdinal = [currentDate xx_weekOfMonth]; // 这个月的第几周

你可能感兴趣的:(获取本周是这月的第几周)