how to format a date time variable in asp.net mvc using @HTML.DisplayNameFor
<p>I have this statement in my view that as follows: </p>

<pre><code>&lt;th&gt;           
    @Html.DisplayNameFor(model =&gt; model.ReleaseDate)
&lt;/th&gt;
</code></pre>

<p>all I'm trying to do is format the release date so that it will be in the format of mm/dd/yyyy. I've searched loads and haven't come across anything that is exactly what I'm looking for. Any help would be greatly appreciated, I'm relatively new to coding.</p>

<p>Here is my Model:</p>

<pre><code>using System;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity;

namespace MvcMovie2.Models
{
    public class Movie
    {
        public int ID { get; set; }
        public string Title { get; set; }
        public DateTime ReleaseDate { get; set; }
        public string Genre { get; set; }
        public string Rating { get; set; }
        public decimal Price { get; set; }
    }

    public class MovieDBContext : DbContext
    {
        public DbSet&lt;Movie&gt; Movies { get; set; }
    }

    public class DummyModel : Movie
    {
        [DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}")]
        public DateTime ReleaseDate { get; set; }
    }
}
</code></pre>

<p>and here is my view:</p>

<pre><code>@model IEnumerable&lt;MvcMovie2.Models.Movie&gt;

@{
    ViewBag.Title = "Index";
}

&lt;h2&gt;Index&lt;/h2&gt;

&lt;p&gt;
    @Html.ActionLink("Create New", "Create")
&lt;/p&gt;
&lt;table class="table"&gt;
    &lt;tr&gt;
        &lt;th&gt;
            @Html.DisplayNameFor(model =&gt; model.Title)
        &lt;/th&gt;
        &lt;th&gt;           
            @Html.DisplayFor(model =&gt; model.ReleaseDate)
        &lt;/th&gt;
        &lt;th&gt;
            @Html.DisplayNameFor(model =&gt; model.Genre)
        &lt;/th&gt;
        &lt;th&gt;
            @Html.DisplayNameFor(model =&gt; model.Rating)
        &lt;/th&gt;
        &lt;th&gt;
            @Html.DisplayNameFor(model =&gt; model.Price)
        &lt;/th&gt;
        &lt;th&gt;&lt;/th&gt;
    &lt;/tr&gt;

@foreach (var item in Model) {
    &lt;tr&gt;
        &lt;td&gt;
            @Html.DisplayFor(modelItem =&gt; item.Title)
        &lt;/td&gt;
        &lt;td&gt;
            @Html.DisplayFor(modelItem =&gt; item.ReleaseDate)
        &lt;/td&gt;
        &lt;td&gt;
            @Html.DisplayFor(modelItem =&gt; item.Genre)
        &lt;/td&gt;
        &lt;td&gt;
            @Html.DisplayFor(modelItem =&gt; item.Rating)
        &lt;/td&gt;
        &lt;td&gt;
            @Html.DisplayFor(modelItem =&gt; item.Price)
        &lt;/td&gt;
        &lt;td&gt;
            @Html.ActionLink("Edit", "Edit", new { id=item.ID }) |
            @Html.ActionLink("Details", "Details", new { id=item.ID }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.ID })
        &lt;/td&gt;
    &lt;/tr&gt;
}

&lt;/table&gt;
</code></pre>