- (NSString*)weekdayStringFromDate:(NSDate*)inputDate {
NSArray*weekdays = [NSArrayarrayWithObjects: [NSNullnull],@"周日",@"周一",@"周二",@"周三",@"周四",@"周五",@"周六",nil];
NSCalendar*calendar = [[NSCalendaralloc]initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
NSTimeZone*timeZone = [[NSTimeZonealloc]initWithName:@"Asia/Shanghai"];
[calendarsetTimeZone: timeZone];
NSCalendarUnitcalendarUnit =NSCalendarUnitWeekday;
NSDateComponents*theComponents = [calendarcomponents:calendarUnitfromDate:inputDate];
return[weekdaysobjectAtIndex:theComponents.weekday];
}
调用:
NSDate*date = [NSDate date];
NSString *str= [self weekdayStringFromDate:date];