I have to display month number instead of it’s name
i am using type=’month’ in html.helper
@Html.EditorFor(model => model.DueMonth, new
{
htmlAttributes = new
{
@class = "form-control",
type = "month",
@Value = Model.DueMonth!= null ?
Model.DueMonth.Date.ToString("yyyy-MM") : null
}
})
**
but it is displaying
March 2023
i have to display 03 2023**
2
Answers
Instead of "yyyy-MM" use "MM yyyy".
Like this
The UI provided by the
input type="date"
is controlled by the browser (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/month). If you want to control the format, you can do one of three things:text