NSCalendar *calendar = [[NSCalendaralloc] initWithCalendarIdentifier:NSChineseCalendar];//NSGregorianCalendar
/*
NSGregorianCalendar
NSChineseCalendar];
NSJapaneseCalendar
*/
NSDate *now;
NSDateComponents *comps = [[NSDateComponentsalloc] init];
NSInteger unitFlags =NSYearCalendarUnit | NSMonthCalendarUnit |NSDayCalendarUnit | NSWeekdayCalendarUnit |
NSHourCalendarUnit | NSMinuteCalendarUnit |NSSecondCalendarUnit;
now=[NSDate date];
comps = [calendarcomponents:unitFlags fromDate:now];
NSLog(@"currentDate is %@",now);
不过得到的系统时间不准确,比正确的系统时间多了四个小时---原因还要进一步研究中
补充:这个可以得到正确的时间
NSDate *today = [[NSDate alloc]init];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
NSString *currentTime = [dateFormatter stringFromDate:today];
[dateFormatter release];
[today release];
NSLog(@"date is %@",currentTime);