how to convert date with 'T' to/from string in C#

前端 未结 4 1848
无人及你
无人及你 2021-01-04 12:57

I used following functions to convert DateTime from/into string:

DATE_OBJ.ToString(DATE_FORMAT);

DateTime.ParseExact(Date_string,          


        
4条回答
  •  长发绾君心
    2021-01-04 13:17

    You can go from DateTime to that format with

    DateTime dt = new DateTime();
    dt.ToString("o");
    

    and from that format to DateTime with

    DateTimeOffset.Parse(dateString);
    

    Here is some more info on DateTime format: http://www.dotnetperls.com/datetime-format

提交回复
热议问题