I am trying to get the month and year to appear instead of dd/mm/yyyy. My code is below:
Heres the model code
[Display (Name = "ValidFrom")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:MMM-yyyy}" , ApplyFormatInEditMode = true)]
public System.DateTime ValidFrom { get; set; }
This is view file
<div class="form-group">
@Html.LabelFor(model => model.ValidFrom, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.ValidFrom, new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.ValidFrom, "", new { @class = "text-danger" })
</div>
</div>
Is there a way where I can only make mm/yyyy appear?