Date format for 2016-10-20T13:01:47.317

前端 未结 4 1039
别那么骄傲
别那么骄傲 2021-01-26 04:44

This is what I am trying for getting date from the string 2016-10-20T13:01:47.317 but getting nil

NSDateFormatter *dateFormatter1 =         


        
4条回答
  •  醉话见心
    2021-01-26 05:23

    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]);
    

提交回复
热议问题