(nullable NSDate )dateFromString:(NSString )string;
这个方法之前可以用,现在获取到的date 为nil
曾经蜡笔没有小新2017-04-27 09:04:47
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
阿神2017-04-27 09:04:47
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];