iOS 获取当前日期星期几
2017-03-20 本文已影响1002人
任任run
//获取当前日期星期几
NSArray *weekdays = [NSArray arrayWithObjects:@"周日", @"周一", @"周二", @"周三", @"周四", @"周五", @"周六", nil];
NSTimeZone *timeZone = [[NSTimeZone alloc] initWithName:@"Asia/Shanghai"];
[calendar setTimeZone: timeZone];
NSDate *date = [NSDate date];
NSCalendarUnit calendarUnit = NSWeekdayCalendarUnit;
NSDateComponents *theComponents = [calendar components:calendarUnit fromDate:date];
NSLog(@"%@", [weekdays objectAtIndex:theComponents.weekday]);