[Solved] 2017-08-16 05:08:54 Convert String to in Date “17-Aug 13 : 30” using swift 3


The input is yyyy-MM-dd hh:mm:ss and the output is dd-MMM HH:mm.So do like

    let outFormatter = DateFormatter()
    // set the input format
    outFormatter.dateFormat = "yyyy-MM-dd hh:mm:ss"
    // convert your string to date
    let date = outFormatter.date(from: "2017-08-16 05:08:54")!
    // set the output format 
     outFormatter.dateFormat = "dd-MMM HH : mm"
    // convert your date to expected output string
    let outStr = outFormatter.string(from: date)
    print(outStr) // -> outputs 16-Aug 05 : 08  

5

solved 2017-08-16 05:08:54 Convert String to in Date “17-Aug 13 : 30” using swift 3