I need to capture date and time both for my model property. In my model class I have the following
[Required]
[DataType(DataType.DateTime)]
public DateTime?
In my case in my Model I had :
[DisplayFormat(DataFormatString = "{0:dd MMM yyyy}", ApplyFormatInEditMode = true)].
In my view in my script, I had:
$(function () {
$('.datepicker').datepicker({
changeMonth: true,
changeYear: true,
format: "dd MMM yyyy"
});
});
When I changed my script's format to format: dd M yyyy - it worked.