Strange .NET DateTime issue (Month is 00??)

.net, c#, datetime

Solution

This is because of a bad format string somewhere, probably confusing `"MM"` (month) with `"mm"` (minute), like @Silvermind said in a comment to the question. I can reproduce the problem like this:

var badCulture = new CultureInfo("");
badCulture.DateTimeFormat.ShortDatePattern = "dd-mm-yyyy";
Thread.CurrentThread.CurrentCulture = badCulture;

var testDate = new DateTime(2013, 4, 24);  // debug and rest mouse over variable

So check if someone used a bad format string somewhere.

Problem

As you can see below, I encounter a strange behaviour. I am trying to instantiate a DateTime with a year, a month and a day (easy!). But in debug mode, Date displays 00 for the month, while Month displays 4! Maybe a configuration problem in my solution? I work in an ASP .NET MVC 4 application.

Original source