NSDate *todayDate=[NSDate date];
NSDateFormatter *dateFormatter=[[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"YYYYMMddHHmmss"];
NSString *todayDateString=[dateFormatter stringFromDate:todayDate];
获取的时间有时候出现在中间出现非数字字符:
处理方法:
NSCharacterSet *setToRemove =[[ NSCharacterSet characterSetWithCharactersInString:@"0123456789"] invertedSet];
NSString *newtimedate = [[todayDateString componentsSeparatedByCharactersInSet:setToRemove] componentsJoinedByString:@""];
处理后,就不会出现格式错误情况。