ASP.NET MVC displaying date without time
This should do it for edit mode and display
[DisplayFormat(ApplyFormatInEditMode = true,DataFormatString = "{0:MM/dd/yyyy}")]
though if it is just display, this might work
[DisplayFormat(DataFormatString = "{0:d}")]
Use DisplayFormatAttribute to indicate format when value is displayed. Also, you could create two DisplayTemplates, Date and DateTime, and use UIHintAttribute to specify template
The problem you have here is that you are using a string value rather than a DateTime.
change your model to be:
[DataType(DataType.Date)]
[Display(Name = "Date of birth")]
public DateTime? DateOfBirth { get; set; }
DataType will only work if it's a DateTime type, you also get the added advantage that it will automatically validate it as a valid date when using a DateTime. If you use string, you will have to use a regular expression validator to ensure a proper date has been entered.
You can use ToShortDateString() or ToLongDateString() to display date only,example:
@Model.EventDate.ToShortDateString()
@Model.EventDate.ToLongDateString()