CST时间转换成 yyyy-MM-dd格式

将 "Tue Oct 28 12:12:10 CST 2010" 时间格式转成 "2010-10-28 12:12:10" 格式:

+ (NSString *)getDataByCSTTime:(NSString *)timeString
{
    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:timeString];
    NSDateFormatter* outputFormatter = [[NSDateFormatter alloc] init];
    [outputFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSString* newDateString = [outputFormatter stringFromDate:formatterDate];
    return newDateString;
}

posted @ 2015-09-14 16:50  vsignsoft  阅读(1085)  评论(0编辑  收藏  举报