i want to convert this string into DateTime.
Tue Aug 19 15:05:05 +0000 2008
I have tried the following code, but not getting the proper value.
string strDate = "Tue Aug 19 15:05:05 +0000 2008";
DateTime date;
DateTime.Parse(strDate,out date);
i want to convert this string into DateTime.
Tue Aug 19 15:05:05 +0000 2008
I have tried the following code, but not getting the proper value.
string strDate = "Tue Aug 19 15:05:05 +0000 2008";
DateTime date;
DateTime.Parse(strDate,out date);
DateTime date = DateTime.ParseExact(
"Tue Aug 19 15:05:05 +0000 2008",
"ddd MMM dd HH:mm:ss zzz yyyy",
CultureInfo.InvariantCulture
);
For more safety use TryParseExact method:
string str = "Tue Aug 19 15:05:05 +0000 2008";
string format = "ddd MMM dd HH:mm:ss zzz yyyy";
DateTime date;
if (DateTime.TryParseExact(str, format, CultureInfo.InvariantCulture,
DateTimeStyles.None, out date))
{
Console.WriteLine(date.ToString());
}