×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Dealing with Datetimeoffset Serialization to Strings
 

Submitted by: Srinath M S(srinath_ms@yahoo.com)

Friday May 18th 2018 by Srinath M S

Language: .NET, Expertise: Intermediate - DateTimeOffSet values are often converted to strings for display but they often fail when they are converted back.

DateTimeOffSet values are often converted to strings for display or some other purpose. But these representations often fail when they are used to convert them back to valid date/time values.

We need to use the ToString method's overload and pass the "u" or "s" formats as they are culture-invariant.

For example:

DateTimeOffSet d = DateTimeOffSet.Now;
Console.WriteLine(d.ToString("u"));
Home
Mobile Site | Full Site
Copyright 2018 © QuinStreet Inc. All Rights Reserved