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ç
  • 97,365
  • 13
  • 115
  • 182
Dživo Jelić
  • 1,604
  • 2
  • 22
  • 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
  • 55,739
  • 12
  • 86
  • 122