//获取日期
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 year=[comps year];
int month = [comps month];
int day = [comps day];
NSLog(@"%@",[NSString stringWithFormat:@"%d年%d月",year,month]);
NSLog(@"%@",[NSString stringWithFormat:@"%d",day]);
NSLog(@"%@",[NSString stringWithFormat:@"%@",[arrWeek objectAtIndex:week]]);