title: MVC 5 Format Datetime in Model
body: <p>I have several DateTime fields in my database. Normaly I have just created this in my model like this:</p>
  
  <pre><code>[Display(Name = "Downtime start")]
  public DateTime? Downtime_start { get; set; }
  </code></pre>
  
  <p>Note: It has to be nullable.</p>
  
  <p>So this works fine. But the problem is that it also show the seconds everywhere, which is abit annoing.</p>
  
  <p>So can't I just fix this by doing some parsing in my Model? Something like this?</p>
  
  <pre><code>private string Parsed_Downtime_start;
  
  [Display(Name = "Downtime_start")]
  public DateTime? Downtime_start
  {
      get 
      {
          if (Parsed_Downtime_start != null)
          {
              return DateTime.Parse(Parsed_Downtime_start);
          }
          else 
          {
              return null;
          }
  
      }
      set 
      {
          if (value != null)
          {
              Parsed_Downtime_start = value.Value.ToString("MM/dd/yyyy hh:mm tt");
          }
          else
          {
              Parsed_Downtime_start = null;
          }
  
      }
  }
  </code></pre>
  
  <p>This doesn't really change anything. But if I do it the other way and save it to the DB as string and parse it out as DateTime it works fine. But I dont really want to save the DateTimes in the DB as String.</p>