0

I have this string:

Fri, 13 Jan 2012 04:26:42 PST

I tries to parse it like that:

DateTime.TryParse("Fri, 13 Jan 2012 04:26:42 PST", out date)

Or like that:

Convert.ToDateTime("Fri, 13 Jan 2012 04:26:42 PST")

And it throws to me:

MESSAGE: The string was not recognized as a valid DateTime. There is an unknown word starting at index 26.

Any idea what is wrong and how can I fix it?

Nir
  • 2,497
  • 9
  • 42
  • 71

2 Answers2

0

its impossible to do it by default function such as , convert , format .. etc.you should write a function to parse it manualy.in it ,extract the weekday & time & date ... then create a valid date string or directly a date variable.

msk
  • 63
  • 8
0

With named timezones, you can create a dictionary that maps the names to the actual timezone difference in the format recognized - then, use this dictionary to replace named timezones with their recognized format.

At this point you will have a string that can be parsed by the framework.

Dictionary<string,string> namedToActualTZ = new Dictionary<string,string>();
namedToActualTZ.Add("PST", "-0800");
Oded
  • 489,969
  • 99
  • 883
  • 1,009