1

I have the following date string Tue Jan 06 2015 17:31:25 GMT-0500

When i try to parse it i'm getting the following exception: Additional information: String was not recognized as a valid DateTime.

model.UpdatedDate = DateTime.ParseExact("Tue Jan 06 2015 17:31:25 GMT-0500", "ddd MMM dd yyyy HH:mm:ss ZZZZ", new CultureInfo("en-US"));
Alao
  • 390
  • 5
  • 11

1 Answers1

2

I don't think ZZZZ is a valid format specifier. Try this format string:

"ddd MMM dd yyyy HH:mm:ss 'GMT'zzz"
AJ Richardson
  • 6,610
  • 1
  • 49
  • 59
  • 1
    @Alao: Note also the need to put the `GMT` in single quotes, to specify it as a literal string in the format. – Peter Duniho Jan 08 '15 at 02:12
  • I was using the JavaScript library momment to convert the Json date into a usable format. I ended up removing the GMT. – Alao Jan 09 '15 at 04:08