objective-c - NSString 转 NSDate
给我你的怀抱
给我你的怀抱 2017-04-27 09:02:47
0
2
512
  • (nullable NSDate )dateFromString:(NSString )string;
    这个方法之前可以用,现在获取到的date 为nil

给我你的怀抱
给我你的怀抱

reply all(2)
曾经蜡笔没有小新

This should be the conversion between NSDate and NSString. You can use this method to convert after getting the date, instead of using this method to get the date

阿神

1. First, the NSString passed in must be in a fixed format.
2. Then set NSDateFormatter to follow the same format.
3. Convert to time. If it is still nil... (As if I didn't say it----)

 NSString *str =  @"2015-11-26 17:51:51"; 
 NSDateFormatter *dateformatter = [[NSDateFormatter alloc] init];
 [dateformatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
 NSDate *date = [dateformatter dateFromString: str];
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template