I have the following Razor
<td>@Html.TextBoxFor(m => m.MeetingToEdit.StartTime, new { @class = "datetimepicker form-control", @Value = Model.MeetingToEdit.StartTime })</td>
I access the date from the Controller as
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult UpdateMeetingWithId([Bind(Prefix = "MeetingToEdit")]Meeting model)
{
Meeting meeting = meetingsContext.Meetings.Where(a => a.Id == model.Id).First();
meeting.Title = model.Title;
meeting.StartTime = model.StartTime;
meeting.EndTime = model.EndTime;
meetingsContext.Entry(meeting).State = System.Data.Entity.EntityState.Modified;
meetingsContext.SaveChanges();
return RedirectToAction("ReinviteVisitor2", "Home", new { visitorId = model.SubjectId });
}
So when debugging the chtml, Model.MeetingToEdit.StartTime is correct however when it gets displayed in the textbox in the webpage it is wrong and becomes "Jan 14, 0044 12:00 AM". What is the correct way to ensure the datetime is displayed correctly in the textfield?
EDIT: I am using bootstrap datetimepicker and it is configured as follows:
<script>
$(document).ready(function () {
$('.datetimepicker').datetimepicker({
format: 'lll'
});
});
</script>