i have a model like this :
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:yyyy/MM/dd HH:mm:ss}", ApplyFormatInEditMode = true)]
public DateTime DateUpdate { get; set; }
and have a view :
<div class="form-group">
@Html.LabelFor(model => model.DateUpdate, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Helpers.EditVal(Html.EditorFor(m => m.DateUpdate, new { htmlAttributes = new { @class = "form-control", @Value = DateTime.UtcNow.ToString("yyyy/MM/dd HH:mm:ss") } }))
@Html.ValidationMessageFor(model => model.DateUpdate, "", new { @class = "text-danger" })
</div>
</div>
but i can't save it because i get validation error for dateupdate field ! what is wrong here ? i want to save this format {0:yyyy/MM/dd HH:mm:ss}
not mm/dd/yy or something else and i don't want to get validation error