I have an ISO 8601 type DateTime string that can come in 2 different forms that I need to parse into a normal local TimeDate in .Net. One like this 2017-12-29T14:49:53.857-06:00 and like this 1974-09-07T00:00:00-05:00 mainly where the seconds is a fractional part and not. How is the best way to do this?
I've tried this for this format, but it doesn't work.
var date= DateTime.ParseExact("1974-09-07T00:00:00-05:00", "yyyy-MM-ddThh:mm:ss zzz", CultureInfo.InvariantCulture);
And this for this format, but it doesn't work.
var date= DateTime.ParseExact("2017-12-29T14:49:53.857-06:00", "yyyy-MM-ddThh:mm:ss.sss zzz", CultureInfo.InvariantCulture);