NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
NSString *dateString = @"2000-01-01";
[dateFormatter setDateFormat:@"yyyy-MM-dd"];//setDateFormat必须一致
[self dataFromString:dateString withFormat:@"yyyy-MM-dd"];
- (void)dataFromString:(NSString*)dateStr withFormat:(NSString*)format{
NSDateFormatter *formater1 = [[NSDateFormatter alloc] init];
[formater1 setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@"UTC"]];//消除时差8小时
[formater1 setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];//date返回不为空
[formater1 setDateFormat:format];
NSDate *date1 = [formater1 dateFromString:dateStr];
NSLog(@"date1======%@",date1);
}