我在 MVC5 和 EntityFramework 中工作以将数据显示到 View 中。
现在在我看来数据格式是:- 10/22/2014 12:00:00 AM
但我只想要日期:- 22/10/2014 这种格式
我试试这个代码,但它不起作用
@if (item.chekin_on_after != null)
{ @Html.DisplayFor(modelItem => item.chekin_on_after, "ShortDateTime")}
我也关注了 stackoverflow 中的几个链接,但没有帮助 Date Format using Html.DisplayFor() in MVC5 , Display only date and no time
最佳答案
我没用过 @html.DisplayFor()
. 而不是我用
@Convert.ToString(string.Format("{0:dd/MM/yyyy}", item.chekin_on_after))
它完美地工作。
关于entity-framework - MVC中@Html.DisplayFor()只显示日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26464319/