2016-11-01T00:00:00+08:00转换为2016-11-01 00:00:00
主要是这个yyyy-MM-dd'T'HH:mm:ssZZZZ,要正确匹配时间格式
下面是代码:
+(NSString *) timeChange:(NSString *)timeString
{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZZZZ"];
NSDate *currentDate = [dateFormatter dateFromString:timeString];
NSDateFormatter *outputFormatter = [[NSDateFormatter alloc]init];
[outputFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSString *timeChanged = [outputFormatter stringFromDate:currentDate];
NSLog(@"datestr = %@", timeChanged);
return timeChanged;
}