0

i have a string which is "26052014153850" it is in the format of date month year hour minute second. i want to convert this to date and time format but its showing string is not recognized as valid date and time

string result ="26052014153850";
 DateTime dt = DateTime.ParseExact(result, "dd/MM/yyyy/HH/mm/ss", CultureInfo.InvariantCulture);
asked May 27, 2014 at 4:59
1

1 Answer 1

4
 DateTime dt = DateTime.ParseExact
 (result, "ddMMyyyyHHmmss", CultureInfo.InvariantCulture);

The format of the string representation must match the specified format exactly.
Read this for more from MSDN.

answered May 27, 2014 at 5:00

3 Comments

capital "HH" will make it count 24 hours, "hh" would only count till 12.
@user2380844 Yes, I have changed. Good luck.
@FarhadJabiyev, adding description about the solution in the answer would make it easy to understand.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.