iOS 获取当前日期星期几

//获取当前日期星期几

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]);

你可能感兴趣的:(iOS 获取当前日期星期几)