1
DateTime startDate = DateTime.ParseExact("2011-05-25 24:00:00", "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture);

for some reason parsing this string to a datetime does not want to work. I Tried several things already but it just does not want to work. Most of the internet examples do it like this too. Does someone sees what is wrong?

thanks

4
  • 1
    It's probably the 24:00:00 try 00:00:00 instead Commented May 25, 2011 at 21:15
  • 1
    24? Hours should be in 0 to 23 range. Commented May 25, 2011 at 21:15
  • 1
    java's SimpleDateFormat has H for (0 - 23) and k for (1 - 24). I wonder if .NET has anything like that. Commented May 25, 2011 at 21:19
  • @Bala: no, there is nothing like that in .NET (at least not that I am aware of). Commented May 25, 2011 at 21:30

1 Answer 1

6

"24:00:00" is not a valid time. Should probably be "00:00:00". If you meant the second that comes after 2011-05-25 23:59:59, that would be 2011-05-26 00:00:00.

For more information about valid value ranges for different format specifiers, check Custom Date and Time Format Strings at MSDN.

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.