Getting exception when converting UTC format DateTime string to date time
Run-time exception (line 16): String was not recognized as a valid DateTime.
Stack Trace:
[System.FormatException: String was not recognized as a valid DateTime.] at System.DateTimeParse.ParseExact(String s, String format, DateTimeFormatInfo dtfi, DateTimeStyles style) at System.DateTime.ParseExact(String s, String format, IFormatProvider provider) at Program.Main() :line 16
string launchMeetingDate = "2020-10-27T09.29.00.000Z";
var launchDate = Helper.ConvertStringToUTCDateTime(launchMeetingDate);
public static DateTime ConvertStringToUTCDateTime(string date)
{
DateTime dateTime;
bool isDateTime = DateTime.TryParse(date, out dateTime);
return dateTime.ToUniversalTime();
}
Please Try This
DateTimeString = "2020-10-27T09:29:00.000Z"