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))
1
  • use shortDate Conversion Commented Oct 9, 2011 at 5:59

3 Answers 3

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}")]
Sign up to request clarification or add additional context in comments.

Comments

1

I found this solution to be quick and easy

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

Comments

-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();

2 Comments

No over load Method for DisplayTextfor Takes two Arguments
anyone facing this issue check this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.