在MVC中显示@ Html.DisplayFor()中的日期 [英] Display only Date in @Html.DisplayFor() in MVC
本文介绍了在MVC中显示@ Html.DisplayFor()中的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在MVC5和EntityFramework中工作,用于在View中显示数据。
现在我的观点数据格式是: - 10/22/2014 12:00:00 AM
但我只想要日期: - 22/10/2014这种格式
我尝试这段代码,但它不工作
$ b ${@ Html.DisplayFor(modelItem => item.chekin_on_after,ShortDateTime)}
$ $ $
我还在stackoverflow中关注几个链接,但没有帮助使用MVC5中的Html.DisplayFor()的日期格式,仅显示日期和时间
解决方案
我不使用@ html.DisplayFor()代替这个我使用
@ Convert.ToString(string.Format( {0:dd / MM / yyyy},item.chekin_on_after))
它的工作完美
I work in MVC5 and EntityFramework for displaying data into View.
right now in my view data format is :- 10/22/2014 12:00:00 AM But i want only date :- 22/10/2014 in this format
i try this code but it not working
@if (item.chekin_on_after != null)
{ @Html.DisplayFor(modelItem => item.chekin_on_after, "ShortDateTime")}
I also follow few link in stackoverflow but not helpful Date Format using Html.DisplayFor() in MVC5, Display only date and no time
解决方案
i not use @html.DisplayFor() in place of this i use
@Convert.ToString(string.Format("{0:dd/MM/yyyy}", item.chekin_on_after))
And it work perfectly
这篇关于在MVC中显示@ Html.DisplayFor()中的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文