1

I am trying to format the DateTime to Just display just date with out time.

Can any one suggest on that please?

@Html.DisplayTextFor("", String.Format("{0:dddd, MM/dd/yyyy}", Model.DOB))
HaBo
  • 13,999
  • 36
  • 114
  • 206

3 Answers3

2

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}")]
Flea
  • 11,176
  • 6
  • 72
  • 83
1

I found this solution to be quick and easy

 @Html.FormatValue(item.PostDate,"{0:dd-mm-yyyy}")
-2

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();
Syeda
  • 1,215
  • 11
  • 23