What is the correct format to use for Date/Time in an XML file

前端 未结 5 1091
温柔的废话
温柔的废话 2020-11-27 15:50

What format do I use for Date/Time when writing to an XML file using .NET? Do I simply use DateTime.ToString(), or do I have to use a specific format?

5条回答
  •  [愿得一人]
    2020-11-27 16:31

    If you are manually assembling the XML string use var.ToUniversalTime().ToString("yyyy-MM-dd'T'HH:mm:ss.fffffffZ")); That will output the official XML Date Time format. But you don't have to worry about format if you use the built-in serialization methods.

提交回复
热议问题