title: Formatting MVC model TimeSpan field
body: <p>I have a MVC page containing a few timepickers. These are stored in a list of objects in the model as nullable <code>TimeSpan</code>. The problem is that I get the timespans printed with seconds into the input fields. Is there some way to format these model properties so that I get the timespans printed in some other way (like <code>7:00</code>, instead of <code>07:00:00</code>)? Needless to say, my "suggestion" of <code>[DisplayFormat...]</code> didn't work. At least not the way I hoped.</p>
  
  <p>The input fields are defined like this:</p>
  
  <pre><code>@Html.TextBoxFor(x =&gt; x.Shifts[i].Start)
  </code></pre>
  
  <p>The relevant part of the model looks like:</p>
  
  <pre><code>public class Workshift
  {
      [DisplayFormat(Something here perhaps?)]
      public TimeSpan? Start { get; set; }
      public TimeSpan? End { get; set; }
      public TimeSpan? Pause { get; set; }
  }
  
  public class TimeRegistrationViewModel
  {
      public List&lt;Workshift&gt; Shifts { get; set; }
  
      ...
  }
  </code></pre>
  
  <p>Appreciate it as always!</p>