[Solved] Converting string to valid DateTime


Try this…

var test = "2015-05-08T05:00Z";
DateTime testTime = new DateTime();
testTime = DateTime.Parse(test, null, System.Globalization.DateTimeStyles.RoundtripKind);

Console.WriteLine(testTime);
Console.ReadLine();

Or even with DateTime.ParseExact()

var test = "2015-05-08T05:00Z";

DateTime testTime = new DateTime();
testTime = DateTime.ParseExact(test, "yyyy-MM-ddTHH:ssZ", System.Globalization.CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind);

Console.WriteLine(testTime);
Console.ReadLine();

Results:

enter image description here

1

solved Converting string to valid DateTime