0

I am getting error while converting string to datetime.

string dateStarted= "Wed Nov 27 2019 20:37:46 GMT+0700 (Indochina Time)";
DateTime startedDate = DateTime.Parse(dateStarted);
3
  • 1
    What is the error you're getting with this code? Commented Nov 27, 2019 at 13:46
  • String was not recognized as a valid DateTime Commented Nov 27, 2019 at 13:47
  • Method Parse(string) uses your current Culture information. Are you sure that the string you are trying to parse suits your current Culture? Commented Nov 27, 2019 at 13:53

1 Answer 1

3

You should use ParseExact to convert string to datetime

var date = DateTime.ParseExact(
                    "Wed Nov 27 2019 20:37:46 GMT+0700 (Indochina Time)",
                   "ddd MMM dd yyyy HH:mm:ss 'GMT+0700 (Indochina Time)'",
                    CultureInfo.InvariantCulture);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.