NSDate *date = [NSDate date];
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *comps;
//年月日
comps = [calendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit) fromDate:date];
NSInteger year = [comps year];
NSInteger rmonth = [comps month];
NSInteger day = [comps day];
//时分秒
comps = [calendar components:(NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit) fromDate:date];
NSInteger hour = [comps hour];
NSInteger minute = [comps minute];
NSInteger second = [comps second];
//星期几
comps = [calendar components:(NSWeekCalendarUnit | NSWeekdayCalendarUnit | NSWeekdayOrdinalCalendarUnit) fromDate:date];
NSInteger week = [comps week];//今年的第几周
NSInteger weekdayOrdinal = [comps weekdayOrdinal];//这个月的第几周
NSInteger weekday = [comps weekday];//星期几(周日是“1”,周一是“2”)