title: MVC 4 Editor Template for Displaying Time in HH:mm Format
body: <p>Working with <code>MVC 4</code> &amp; I created a Editor template to show only the time in <code>HH:mm</code> format from <code>DateTime</code> object</p>
  
  <p>Editor Template Code (TimePicker.cshtml)</p>
  
  <pre><code>@model DateTime?
  @{
      String modelValue = "";
      var dateFormat = System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat;
      var id = "";
      var cls = "";
      var style = "";
      var placeholder = "";
  
      if (ViewData["_id"] != null)
      {
          id = (string)ViewData["_id"];
      }
      if (ViewData["_class"] != null)
      {
          cls = (string)ViewData["_class"];
      }
      if (ViewData["_style"] != null)
      {
          style = (string)ViewData["_style"];
      }
      if (ViewData["_placeholder"] != null)
      {
          placeholder = (string)ViewData["_placeholder"];
      }
  
      if (Model.HasValue)
      {
          if (Model.Value != DateTime.MinValue)
          {
              modelValue = Model.Value.ToString("HH:mm", dateFormat);
          }
      }
  }
  @Html.TextBox("", modelValue, 
             new { @class = cls, @id = id, @style = style, @placeholder = placeholder })
  </code></pre>
  
  <p>In View </p>
  
  <pre><code> @Html.EditorFor(m =&gt; m.StartTime, "TimePicker", new { _id = "StartTime"})
  </code></pre>
  
  <p>But the Final HTML Rendered was </p>
  
  <pre><code> &lt;input id="StartTime" name="StartTime" type="text" value="2013-08-05 0:00:00" /&gt;
  </code></pre>
  
  <p>Even I tried hard coding the value for debugging like below</p>
  
  <pre><code>@Html.TextBox("", "00:00", 
             new { @class = cls, @id = id, @style = style, @placeholder = placeholder })
  </code></pre>
  
  <p>Still I get same <code>2013-08-05 0:00:00</code> instead of <code>0:00</code></p>
  
  <p>What is the problem in the code? </p>
  
  <p><strong>EDIT</strong>: In Quick watch <code>adding name parameter</code> to TextBox gives a result. But it appends it with name attribute, which i dont want. Find this screenshot
  <img src="https://i.stack.imgur.com/yIG8C.png" alt="enter image description here"></p>