字符串转NSDate 格式

Posted Ruby_c

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了字符串转NSDate 格式相关的知识,希望对你有一定的参考价值。

http://www.2cto.com/kf/201407/320341.html

//设置时间格式

    //根据字符串转换成一种时间格式 供下面解析

    NSString* string = ValueModel.addTime;

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

    [inputFormatter setDateFormat:@"yyyyMMddHHmmss"];

    NSDate* inputDate = [inputFormatter dateFromString:string];

    

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

    [outputFormatter setDateFormat:@"yyyyMMdd HH:mm"];

    NSString* strResult = [outputFormatter stringFromDate:inputDate];

以上是关于字符串转NSDate 格式的主要内容,如果未能解决你的问题,请参考以下文章