How do I parse and convert a DateTime to the RFC 3339 date-time format?

后端 未结 5 1785
被撕碎了的回忆
被撕碎了的回忆 2020-12-03 00:22

How do I convert a DateTime structure to its equivalent RFC 3339 formatted string representation and/or parse this string representation back to a DateTime structure? The RF

5条回答
  •  [愿得一人]
    2020-12-03 01:22

    You don't need to write your own conversion code. Just use

    XmlConvert.ToDateTime(string s, XmlDateTimeSerializationMode dateTimeOption)
    

    to parse a RFC-3339 string, and

    XmlConvert.ToString(DateTime value, XmlDateTimeSerializationMode dateTimeOption)
    

    to convert a (UTC) datetime to a string.

    Ref.
    http://msdn.microsoft.com/en-us/library/ms162342(v=vs.110).aspx
    http://msdn.microsoft.com/en-us/library/ms162344(v=vs.110).aspx

提交回复
热议问题