The standard format specifier "O" or "o" corresponds to the custom format string yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffK for DateTime values ββand the string yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'fffffffzzz custom format for DateTimeOffset values.
DateTime lDat = new DateTime(2009, 6, 15, 13, 45, 30, DateTimeKind.Local); Console.WriteLine("{0} ({1}) --> {0:O}\n", lDat, lDat.Kind); // 6/15/2009 1:45:30 PM (Local) --> 2009-06-15T13:45:30.0000000-07:00 DateTimeOffset dto = new DateTimeOffset(lDat); Console.WriteLine("{0} --> {0:O}", dto); // 6/15/2009 1:45:30 PM -07:00 --> 2009-06-15T13:45:30.0000000-07:00
Link: https://msdn.microsoft.com/en-us/library/az4se3k1%28v=vs.110%29.aspx#Roundtrip
source share