我需要在iOS 2013-11-23T18:30:00.000 + 0000
中将此字符串转换为日期我已编写此代码,但始终返回nil
- (NSDate*) textForDueDate
{
// Convert string to date object
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"MM/dd/YYYY"];
NSDate *date = [dateFormat dateFromString:@"2013-11-23T18:30:00.000+0000"];
return date;
}
答案 0 :(得分:2)
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"YYYY-MM-dd'T'HH:mm:ss.SSSZ"];
NSDate *date = [dateFormat dateFromString:@"2013-11-23T18:30:00.000+0000"];
NSLog(@"%@",date);