@Html.EditorFor DateTime not displaying when set a default value to it
Your razor would be as follows:
@Html.TextBoxFor(x => x.Date, "{0:yyyy-MM-dd}", new { @class = "form-control",@type = "date"})
You need to have model class property like below :
[DataType(DataType.Date), Required]
[DisplayFormat(DataFormatString = "{0:yyyy/MM/dd}", ApplyFormatInEditMode = true)]
public DateTime StartTime { get; set; }
[DataType(DataType.Date), Required]
[DisplayFormat(DataFormatString = "{0:yyyy/MM/dd}", ApplyFormatInEditMode = true)]
public DateTime EndTime { get; set; }
When you decorate a model property with [DataType(DataType.Date)]
the default template in ASP.NET MVC
generates an input field of type="date"
.