So I want to convert a certain UTC DateTime string that is in the following format 2020-04-18T20:05:00.000-04:00.
I am trying to use the following function :
DateTime.ParseExact(segment.DepartureDate,"yyyy-MM-ddTHH:mm:ss.fffzzz", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AdjustToUniversal);
for converting the above Date string that i received from an API, to a C# DateTime type variable.
But the Actual Result is {19-04-2020 00:05:00}. Somehow the date gets rounded up or converted which is not what i am expecting.
Have also tried Date.Parse but that filters out the UTC Offset whose value i really need.
Can anyone suggest a legit way to achieve this conversion accurately.Thanks in Advance.