6
I have a field in the database, Date Time, and wanted to display on screen to the user, but in separate fields, being Date and Time.
First displays the Date
@Html.DisplayFor(modelItem => item.DataHora)
Second displays the Hour
@Html.DisplayFor(modelItem => item.DataHora)
I tried to format using the code below, but it didn’t work...
@Html.DisplayFor(modelItem => item.DataHora, {0:dd/MM/yyyy})
Dirt?
I prefer to use a view model and treat it in different properties. Example: public class Mymodel { public Datetime Datahora { get; set; } public string Data { get { Return Datahora.Toshortdatestring(); } } public string Time { get { Return Datatime.Toshorttimestring(); } } }
– Ricardo