I need the date of my model to be displayed in the "dd / mm / yyyy" format in my view, today it displays in the format "yyyy-mm-dd". Here's the snippet of my code:
@Html.DisplayFor(modelItem => item.DataNascimento)
How to implement?
I need the date of my model to be displayed in the "dd / mm / yyyy" format in my view, today it displays in the format "yyyy-mm-dd". Here's the snippet of my code:
@Html.DisplayFor(modelItem => item.DataNascimento)
How to implement?
There are some options to be made, some of them follow
@Html.Label(item.DataNascimento.ToString("dd/MM/yyyy"))
or
@Html.Label(item.DataNascimento.ToShortDateString())
Or
In your class add annotation and so you can use @Html.DisplayFor(modelItem => item.DataNascimento)
that it will respect annotation
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
public DateTime DataNascimento{ get; set; }