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"));
2
  • Here is the date and time format strings list. Commented Jan 8, 2015 at 2:10
  • Thanks and sorry for the duplicate Commented Jan 22, 2015 at 22:50

1 Answer 1

2

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

"ddd MMM dd yyyy HH:mm:ss 'GMT'zzz"
Sign up to request clarification or add additional context in comments.

2 Comments

@Alao: Note also the need to put the GMT in single quotes, to specify it as a literal string in the format.
I was using the JavaScript library momment to convert the Json date into a usable format. I ended up removing the GMT.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.