Date Format using Html.DisplayFor() in MVC5

前端 未结 4 1954
旧时难觅i
旧时难觅i 2021-01-05 11:20

Referencing the answer in this post I added /Views/Shared/DisplayTemplates and added a partial view called ShortDateTime.cshtml as shown below:

@model System         


        
4条回答
  •  南方客
    南方客 (楼主)
    2021-01-05 11:56

    Have you tried this?

    @if (modelItem.BirthDate != null) { Html.DisplayFor(modelItem => item.BirthDate, "ShortDateTime") }
    

提交回复
热议问题