title: Display Time in AM PM from Model with DataAnnotations
body: <p>I am trying to display a Sql Server time field in AM and PM. It displays correcly in edit mode but not in list mode.
  Model:</p>
  
  <pre><code>    public class HMSappointmentMetaData
  {
      public int ID { get; set; }
      [Required(ErrorMessage = "Rep Name is required")]
      [StringLength(50, ErrorMessage = "Max length is 50")]
      public string Rep { get; set; }
      [Required(ErrorMessage = "Customer Name is required")]
      [StringLength(50, ErrorMessage = "Max length is 50")]
      public string Name { get; set; }
      [Required(ErrorMessage = "Address is required")]
      [StringLength(100, ErrorMessage = "Max length is 100")]
      public string Address { get; set; }
      [Required(ErrorMessage = "City is required")]
      [StringLength(50, ErrorMessage = "Max length is 50")]
      public string City { get; set; }
      [Required(ErrorMessage = "Zip is required")]
      [StringLength(50, ErrorMessage = "Max length is 50")]
      public string ZipCode { get; set; }
      [Required(ErrorMessage = "County is required")]
      [StringLength(50, ErrorMessage = "Max length is 50")]
      public string County { get; set; }
      [Required(ErrorMessage = "Home Phone is required")]
      [StringLength(10, ErrorMessage = "Max length is 10")]
      public string HomePhone { get; set; }
      [Required(ErrorMessage = "Mobile Phone is required")]
      [StringLength(10, ErrorMessage = "Max length is 10")]
      public string CellPhone { get; set; }
      [Required(ErrorMessage = "Question is required")]
      [StringLength(50, ErrorMessage = "Max length is 50")]
      public string OwnHome { get; set; }
      [Required(ErrorMessage = "Question is required")]
      [StringLength(50, ErrorMessage = "Max length is 50")]
      public string HaveAttic { get; set; }
      [Required(ErrorMessage = "Question is required")]
      [StringLength(50, ErrorMessage = "Max length is 50")]
      public string AvgElectric { get; set; }
      [Required(ErrorMessage = "Question is required")]
      [StringLength(50, ErrorMessage = "Max length is 50")]
      public string SummerSpike { get; set; }
      [Required(ErrorMessage = "Question is required")]
      [StringLength(50, ErrorMessage = "Max length is 50")]
      public string TriedAny { get; set; }
      [Required(ErrorMessage = "Question is required")]
      [StringLength(50, ErrorMessage = "Max length is 50")]
      public string InsulationType { get; set; }
      [Required(ErrorMessage = "Question is required")]
      [StringLength(50, ErrorMessage = "Max length is 50")]
      public string InsulationAge { get; set; }
      [Required(ErrorMessage = "Question is required")]
      [StringLength(50, ErrorMessage = "Max length is 50")]
      public string LastPaint { get; set; }
      [Required(ErrorMessage = "Question is required")]
      [StringLength(50, ErrorMessage = "Max length is 50")]
      public string Married { get; set; }
      public string Spouse { get; set; }
      [Required(ErrorMessage = "Occupation is required")]
      [StringLength(50, ErrorMessage = "Max length is 50")]
      public string Job { get; set; }
      public string SpouseJob { get; set; }
      public string RetireFrom { get; set; }
      public string SpouseRetireFrom { get; set; }
      [Required(ErrorMessage = "Appointment Date is required")]
      [DataType(DataType.Date)]
      [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)]
      public Nullable&lt;System.DateTime&gt; Date { get; set; }
      [Required(ErrorMessage = "Appointment Time is required")]
      [DataType(DataType.Time)]
      [DisplayFormat(DataFormatString = "{0:hh\\:mm}", ApplyFormatInEditMode = true)]
      public Nullable&lt;System.TimeSpan&gt; Time { get; set; }
      [DisplayFormat(DataFormatString = "{0:hh\\:mm tt}")]
      public System.TimeSpan? TimeForDisplay { get { return (Time.HasValue) ? (System.TimeSpan?)DateTime.Now.TimeOfDay.Add(Time.Value) : null; } }
      public HMSappointmentMetaData()
      {
          Time = new TimeSpan(14,30,0);
      }
  
      [DataType(DataType.MultilineText)]
      public string Comments { get; set; }
      public string CreditScore { get; set; }
  }
  </code></pre>
  
  <p>List View:</p>
  
  <pre><code>&lt;table class="table"&gt;
      &lt;tr&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Name)
          &lt;/th&gt;
  
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.City)
          &lt;/th&gt;
  
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Date)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Time)
          &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.Name)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.City)
              &lt;/td&gt;
  
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.Date)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(model =&gt; model.TimeForDisplay)
              &lt;/td&gt;
  
              &lt;td&gt;
                  @Html.ActionLink("Notes", "Index", "AdminNotes", new { AppointmentID = item.ID }, null) |
                  @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>
  
  <p>This results in 24 hr time (14:30)</p>
  
  <p>Edit View:</p>
  
  <pre><code>@Html.EditorFor(model =&gt; model.Time)
  </code></pre>
  
  <p>This displays the correctly formatted time(2:30 PM).</p>