/*
NSCalendarUnitYear
NSCalendarUnitMonth
NSCalendarUnitDay
NSCalendarUnitHour
NSCalendarUnitMinute
NSCalendarUnitSecond
*/
//当前时间
NSDate * date = [NSDate date];
NSCalendar *calender = [NSCalendar currentCalendar];
NSInteger year = [calender component:NSCalendarUnitYear fromDate:date];
NSInteger month = [calender component:NSCalendarUnitMonth fromDate:date];
NSInteger day = [calender component:NSCalendarUnitDay fromDate:date];
NSInteger hour = [calender component:NSCalendarUnitHour fromDate:date];
NSInteger minu = [calender component:NSCalendarUnitMinute fromDate:date];
NSInteger sec = [calender component:NSCalendarUnitSecond fromDate:date];
NSLog(@"year:%zdmonth:%zdday:%zdhour:%zdminu:%zdsec:%zd",year,month,day,hour,minu,sec);
网友评论