In my model I have:
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
public DateTime StartDate { get; set; }
Unfortunately, It only applies to EditorFor, but I cant assign the EditorFor a class, to enable Jquery Datetime picker, as there is no htmlAttributes
parameter.
@Html.EditorFor(model => model.StartDate)
@Html.TextBoxFor(model => model.StartDate, new { @class = "datePicker", @readonly = "readonly" })
So the first shows only the date, but has no datepicker. The second shows the time too 00:00 but has a datetimepicker.
Note: Dont just say, use model.StartDate.ToString("mm/DD/yyyy")
. It does not work.
How Can I set just the Date. But have a timepicker for it And have readonly, so I cant type any numbers in it.