First of all I am new in C#.
I have to convert a string
like
"Fri, 30 Jul 2021 11:57:58 (UTC)"
into a DateTime
. I've tried serveral format strings (like "ddd, dd MMM yyyy HH:mm:ss"
, "r"
, "R"
). But I always get the error message
String was not recognized as a valid DateTime.
Here is my last code for this:
CultureInfo enUS = new CultureInfo("en-US");
string timeStampFormat = "ddd, dd MMM yyyy HH:mm:ss";
DateTime myDateTime;
myDateTime = DateTime.ParseExact(
stringToFormat,
timeStampFormat,
enUS,
DateTimeStyles.AssumeUniversal);
Thanks for your support.
Best regards Andreas## Heading ##