string value = "Sat Apr 28 2012 11:00:00 GMT-0400 (Eastern Daylight Time)"
I need to convert to date time
I tried doing:
DateTime datetime = DateTime.ParseExact(value, "MM/dd/yyyy hh:mm", null);
or
DateTime datetime2 = Convert.ToDateTime(value);
Exception: String was not recognized as a valid DateTime.
Your string doesn’t match your format.
You need to parse that string a bit before trying to convert it. For example, “Apr 28 2012 11:00:00” could be parsed. But, you’ll need to convert the rest of it yourself.
You may want to look into using
DateTimeOffsetdocumented here, because it can hold time relative to UTC, like your string.Found this is the documentation, pretty close to what you have