I have the following date
string dateTimeText = @"Fri Feb 21 23:07:58 +0000 2020";
I want to parse it:
DateTime.ParseExact(dateTimeText, "D M dd HH:mm:ss +ssss yyyy", new CultureInfo("en-US"));
this implementation throws exception. Thanks
I have the following date
string dateTimeText = @"Fri Feb 21 23:07:58 +0000 2020";
I want to parse it:
DateTime.ParseExact(dateTimeText, "D M dd HH:mm:ss +ssss yyyy", new CultureInfo("en-US"));
this implementation throws exception. Thanks
Well, if +ssss
(+0000
) stands for TimeZone (so +0000
means GMT) the pattern is
"ddd MMM dd HH:mm:ss zzzz yyyy"
I.E.
string dateTimeText = "Fri Feb 21 23:07:58 +0000 2020";
var result = DateTime.ParseExact(
dateTimeText,
@"ddd MMM dd HH:mm:ss zzzz yyyy",
CultureInfo.GetCultureInfo("en-US"));
In case +ssss
and (an corresponding +0000
) are fractions of seconds the pattern will be
"ddd MMM dd HH:mm:ss' +'FFFF yyyy"