全部博文(403)
2012年(403)
分类: 嵌入式
2012-03-10 16:29:21
获取系统日期和时间:
- (NSString *)nowTime{
NSDate *date = [NSDate date];
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *comps;
comps = [calendar components:(NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit |NSMinuteCalendarUnit | NSSecondCalendarUnit) fromDate:date];
return [NSString stringWithFormat:@"%.4d-%.2d-%.2d %.2d:%.2d:%.2d",[comps year],[comps month],[comps day],[compshour],[comps minute],[comps second]];
}