asp.net MVC

DisplayFor date format mvc 5

DisplayFor date format mvc 5, someone asked me to explain?

I want to display the date in the view, but the resulted Date Format is 05/10/2017 12:00:00AM. But I wanted to display like 05-Oct-2017. Before I tried to display using DisplayFor, but it was not suited to display the date format. Finally I found the way to display Date Format.

Instead of using @Html.DisplayFor, I used,

@Convert.ToString(string.Format("{0:dd/MMM/yyyy}", item.DOF))    


Result:

05-Oct-2017

It works perfectly.

Post your comments / questions