title: How to format date in asp.net mvc 5
body: <p>I am trying to format a date in asp.net MVC 5 by setting in a model class but not getting the desired result. Please view the date below:</p>
  
  <p>10/10/2010 12:00:00 AM</p>
  
  <p>I want to change the above date in the following format:-</p>
  
  <p>OCT-10-2014</p>
  
  <p>Please view my model class below</p>
  
  <pre><code>[DisplayFormat(DataFormatString = "{0:MMM-dd-yyyy}", ApplyFormatInEditMode = true)]
  [Required(ErrorMessage = "Date is required")]
   public DateTime? DateOfBirth { get; set; }
  </code></pre>
  
  <p>The above code is not formatting in the required format . Also view my code below which render like a table below.</p>
  
  <pre><code>foreach (var m in Model)
              {
                  &lt;tr style="height: 22px; border-bottom: 1px solid silver"&gt;
                      &lt;td style="width: 150px"&gt;@m.StudentId&lt;/td&gt;
                      &lt;td style="width: 150px"&gt;@m.FirstName&lt;/td&gt;
                      &lt;td style="width: 150px"&gt;@m.LastName&lt;/td&gt;
                      &lt;td style="width: 150px"&gt;@m.DateOfBirth&lt;/td&gt;
                  &lt;/tr&gt;
  </code></pre>
  
  <p>So i also tried the code below which is still not working.</p>
  
  <pre><code>&lt;td style="width: 150px"&gt;@m.DateOfBirth.ToString("MMM/dd/yyyy")&lt;/td&gt;
  </code></pre>
  
  <p>Please correct if iam missing amything in my code, thanks</p>