unable to convert string date in Format yyyyMMddHHmmss to DateTime dart

后端 未结 6 818
不知归路
不知归路 2021-02-07 01:49

i have a string containing date in format yyyyMMddHHmmss (e.g.) (20180626170555) and i am using following code to convert it into date time

dateTimeFromString(         


        
6条回答
  •  名媛妹妹
    2021-02-07 02:02

    to convert from "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'" to 'MM/dd/yyyy hh:mm a'

    date = '2021-01-26T03:17:00.000000Z';
    DateTime parseDate =
        new DateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").parse(date);
    var inputDate = DateTime.parse(parseDate.toString());
    var outputFormat = DateFormat('MM/dd/yyyy hh:mm a');
    var outputDate = outputFormat.format(inputDate);
    print(outputDate)
    

    output 01/26/2021 03:17 AM

提交回复
热议问题