获取系统日期和时间:
- (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],[comps hour],[comps minute],[comps second]];
}