Tried various solutions out there related to DataFormatString
but nothing is working for me for following piece of code (Date Format dd-MM-yyyy
not applying in html Form)
[Column("dateOfBirth")]
[Required]
[DataType(DataType.Date), DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd-MM-yyyy}")]
[Display(Name = "Date Of Birth")]
public virtual DateTime DateOfBirth { get; set; }
and Inside the html
<div class="form-group">
@Html.LabelFor(model => model.DateOfBirth, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.DateOfBirth, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.DateOfBirth, "", new { @class = "text-danger" })
</div>
</div>