NSDate日期格式转换
作者:
FANTASIED | 来源:发表于
2017-05-11 15:25 被阅读25次iOS如何转这种日期格式 Fri Apr 14 00:00:00 CST 2017
NSString *cstString = @"Fri Apr 14 00:00:00 CST 2017";
NSDateFormatter *inputFormatter = [[NSDateFormatter alloc] init];
[inputFormatter setDateFormat:@"EEE MMM dd HH:mm:ss 'CST' yyyy"];
inputFormatter.locale = [[NSLocale alloc]initWithLocaleIdentifier:@"en_US"];
NSDate *formatterDate = [inputFormatter dateFromString:cstString];
NSDateFormatter *outputFormatter = [[NSDateFormatter alloc] init];
[outputFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
NSString *newDateString = [outputFormatter stringFromDate:formatterDate];
NSLog(@"%@", newDateString);
本文标题:NSDate日期格式转换
本文链接:https://www.haomeiwen.com/subject/olegattx.html
网友评论