2

Ok so after some research I haven't found any way to solve my problem .

This is my String to Date conversion code:

DateTime startDate = new DateTime(); startDate = DateTime.ParseExact(this.items[5], "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture); 

And this is the string I want to convert:

"22/2/2013 09:57:32" 

But when I compile I have this error:

String was not recognized as a valid DateTime.

What should I do?

3 Answers 3

4

Your pattern should be "dd/M/yyyy HH:mm:ss"

MM requires leading 0, which is not provided in your input string.

Sign up to request clarification or add additional context in comments.

1 Comment

That was the problem ! Thank you
2

You need a single M instead of MM for month. So format should be: "dd/M/yyyy HH:mm:ss"

Comments

1

Just one 'M' required for Month. EX: "dd/M/yyyy HH:mm:ss"

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.