I am trying to change the format of my DataFormatString from dd/MM/yyyy to MM/yy. The reason is because I want to users to select the dates for their credit card expiry date. I am splitting the HTML into two parts: model and view.
Order.cs
[Display(Name = "Expiration Date")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:MM/yyyy}", ApplyFormatInEditMode = true)]
public DateTime Experation { get; set; }
Address and Payment.cshtml
<div class="form-group">
@Html.LabelFor(model => model.Experation, htmlAttributes: new { @class = "col-lg-2 control-label" })
<div class="col-lg-10">
@Html.EditorFor(model => model.Experation)
@Html.ValidationMessageFor(model => model.Experation, "", new { @class = "text-danger" })
</div>
The above code was my attempt to convert it into MM/yy in my model. However, the result is still dd/MM/yyyy. Is there an error here that I do not know?