I am trying to load in a DateTime value into ASP.NET's built-in date picker. I am successfully retrieving the value date from another source, but the date is not properly displaying. Instead of displaying the value, for example, as 12/02/2015, it incorrectly displays as mm/dd/yyyy (the default value before any date is entered). I don't think the problem is in the controller because the value is retrieved fine.
TO CLARIFY: the problem is that the DateTime does not get displayed at all in the view. It is literally "mm/dd/yyyy", and not a date. The problem isn't that I need the date in a different orientation like dd/mm/yyyy or yyyy/dd/mm.
This section of the model looks like:
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode = true)]
public DateTime? myDate { get; set; }
This section of the controller looks like:
var a = dateFromDataBase; // string
model.myDate = string.IsNullOrEmpty(a.AnswerText) ? (DateTime?) null : Convert.ToDateTime(a.AnswerText); // model.myDate gets vaue, but displays as mm/dd/yyyy, converted to a DateTime value
This section of the view looks like:
@Html.ValidationMessageFor(model => model.myDate)
@Html.EditorFor(model => model.myDate)