I am trying to format the DateTime to Just display just date with out time.
Can any one suggest on that please?
@Htm开发者_开发知识库l.DisplayTextFor("", String.Format("{0:dddd, MM/dd/yyyy}", Model.DOB))
You should try @Html.Raw
@Html.Raw(String.Format("{0:MM/dd/yyyy}", Model.DOB))
Or you can do:
@Html.DisplayFor(m => m.DOB)
and then in your model class have this attribute on the property:
[DisplayFormat(DataFormatString="{0:MM/dd/yyyy}")]
I found this solution to be quick and easy
@Html.FormatValue(item.PostDate,"{0:dd-mm-yyyy}")
Conversion On View Use this one..
@Html.DisplayTextFor("", String.Format("{0:MM/dd/yyyy}", Model.DOB))
and for Conversion in ViewModel you can simply use this..
(DateTime.Now).ToShortDateString();
精彩评论