Generate datetime format for XML

前端 未结 4 613
刺人心
刺人心 2021-01-01 15:03

I\'m trying to generate timestamp for cXML as shown below. Is there any function in C# which I can use to format date time to: 2011-06-09T16:37:17+16:37

e.g.

4条回答
  •  一个人的身影
    2021-01-01 15:16

    Yes, using DateTime.ToString("s"), see this link: Standard Date and Time Format Strings. Be aware that "s" does not include the timezone information, whereas "o" does include both fractional seconds and timezone.

    You can also use the XmlConvert.ToString method, where you can specify the time zone information as well.

提交回复
热议问题