Xml readers usually expect dates / times in a very specific format; you can use it yourself using XmlConvert :
string s = XmlConvert.ToString(DateTime.Now); DateTime when = XmlConvert.ToDateTime(s);
If you are using something else, you will need to read it as a string and use DateTime.TryParseExact (or similar) to indicate the actual format string:
string s = reader.ReadContentAsString(); DateTime when = DateTime.ParseExact(s, "M/d/yy hh:mm tt", CultureInfo.InvariantCulture);
If you use XmlSerializer , you can use the shim property for conversion - let me know if that is what you are doing ...
Marc Gravell Mar 19 '09 at 11:46 2009-03-19 11:46
source share