Parsing the DateTime format to get Format String

前端 未结 4 1538
慢半拍i
慢半拍i 2021-01-03 03:43

I would like to be able to get the format string from a DateTime string.

e.g.

"2012-12-08 15:00:00" => "yyyy-MM

4条回答
  •  天命终不由人
    2021-01-03 04:48

    You can try by writing the below code to get yyyy/dd/MM HH:mm format.

    DateTimeFormatInfo df1 = new DateTimeFormatInfo();
    df1.SortTimePattern();
    

    It would give you same HH:mm format.

提交回复
热议问题