This is what I am trying for getting date from the string 2016-10-20T13:01:47.317 but getting nil
NSDateFormatter *dateFormatter1 =
it .317 means milliseconds use SSS
NSDateFormatter *dateFormatter1 = [[NSDateFormatter alloc] init];
[dateFormatter1 setDateFormat:@"yyyy-MM-ddTHH:mm:ss.SSS"]; // or omit the timezone use `yyyy-MM-dd'T'HH:mm:ss.SSS`
NSDate *date = [dateFormatter1 dateFromString:dateString];
Try to use date format as
NSDateFormatter *dateFormatter1 = [[NSDateFormatter alloc] init];
[dateFormatter1 setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSS"];
NSDate *date = [dateFormatter1 dateFromString:dateString];
You need to use this DateFormatter yyyy-MM-dd'T'HH:mm:ss.SSS
in your code
NSDateFormatter *dateFormatter1 = [[NSDateFormatter alloc] init];
[dateFormatter1 setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSS"];
NSDate *date = [dateFormatter1 dateFromString:dateString];
Here date is not nil
Try this for remove millisecond :
NSString *dateString = @"your string";
NSDateFormatter* dateFormatter1 = [[NSDateFormatter alloc] init];
dateFormatter1.dateFormat = @"YYYY-MM-ddTHH:mm:ss.SSS";
NSDate *yourDate = [dateFormatter1 dateFromString:dateString];
dateFormatter1.dateFormat = @"YYYY-MM-ddTHH:mm:ss";
NSLog(@"%@",[dateFormatter1 stringFromDate:yourDate]);