en_US格式的时间字符串Feb 9, 2017转换成NSDate

NSDateFormatter *fomatter = [[NSDateFormatter alloc] init];

[fomatter setDateFormat:@"MMM dd, yyyy hh:mm:ss"];

[fomatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]];

NSDate *date = [fomatter dateFromString:@"Feb 9, 2017 5:21:21"];

NSDateFormatter *formatter2 = [[NSDateFormatter alloc] init];

[formatter2 setDateFormat:@"yyyy年MM月dd日"];

NSString *dateStr = [formatter2 stringFromDate:date];

DDLogInfo(@"%@",dateStr);


en_US格式的时间字符串Feb 9, 2017转换成NSDate_第1张图片
运行结果

你可能感兴趣的:(en_US格式的时间字符串Feb 9, 2017转换成NSDate)