日期转星期几
NSArray *arrWeek=[NSArray arrayWithObjects:@"周日", @"周一", @"周二", @"周三", @"周四", @"周五", @"周六", nil];
NSDate *date = [NSDate date];
NSCalendar *calendar = [ [NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDateComponents *comps = [[NSDateComponents alloc] init];
NSInteger unitFlags = NSYearCalendarUnit |
NSMonthCalendarUnit |
NSDayCalendarUnit |
NSWeekdayCalendarUnit |
NSHourCalendarUnit |
NSMinuteCalendarUnit |
NSSecondCalendarUnit;
comps = [calendar components:unitFlags fromDate:date];
int week = [comps weekday];
int a = week - 1;
NSString *weekStr = [NSString stringWithFormat:@"%@",[arrWeek objectAtIndex:a]];
NSLog(@"啦啦啦 %@",weekStr);