NSCalendar *calendar = [[NSCalendaralloc] initWithCalendarIdentifier:NSGregorianCalendar];
NSDate *now;
NSDateComponents *comps = [[NSDateComponentsalloc] init];
NSInteger unitFlags = NSYearCalendarUnit |NSMonthCalendarUnit | NSDayCalendarUnit |NSWeekdayCalendarUnit |
NSHourCalendarUnit | NSMinuteCalendarUnit |NSSecondCalendarUnit;
now=[NSDatedate];
comps = [calendarcomponents:unitFlags fromDate:now];
int year=[comps year];
int week = [comps weekday];
int month = [comps month];
int day = [comps day];
int hour = [comps hour];
int min = [comps minute];
int sec = [comps second];