0

I got format exception when trying to parse this

// input string "Wed Mar 12 2014 17:50:15 GMT+0000 (UTC)"
DateTime.Parse(response.LastActivityDate); 

A first chance exception of type System.FormatException

How can I parse it this input string ? What culture is this ?

thank you in advance!

Selman Genç
  • 100,147
  • 13
  • 119
  • 184
Dživo Jelić
  • 1,723
  • 3
  • 25
  • 47

1 Answers1

2

Here, have some fish:

string value = "Wed Mar 12 2014 17:50:15 GMT+0000 (UTC)";
value = value.Replace("GMT","").Replace("(UTC)","").Trim();
value = value.Insert(value.Length - 2, ":");
DateTime parsed = DateTime.ParseExact(value, "ddd MMM dd yyyy HH:mm:ss zzz", 
                                      CultureInfo.InvariantCulture);
Adriano Carneiro
  • 57,693
  • 12
  • 90
  • 123