I'm trying to create date strings that meet the requirements of RFC 3339 (for example, "2008-03-19T00: 00: 00.0000000-04: 00"), but I seem to have an offset problem that is not valid. I am using the following:
private string GetDate(DateTime DateTime) { DateTime UtcDateTime = TimeZoneInfo.ConvertTimeToUtc(DateTime); return XmlConvert.ToString(UtcDateTime, XmlDateTimeSerializationMode.Utc); }
but it returns me with a value such as "1977-02-03T05: 00: 00Z"
I also tried using a specific format like
utcDateTime.ToString("yyyy-MM-dd'T'HH:mm:ss.fffK", DateTimeFormatInfo.InvariantInfo);
But with the same results.
See current link: How to parse and convert DateTime to RFC 3339 date and time format?
source share