Q:

MVC 5 Format Datetime in Model

I have several DateTime fields in my database. Normaly I have just created this in my model like this:
[Display(Name = "Downtime start")]
public DateTime? Downtime_start { get; set; }

Note: It has to be nullable.
So this works fine. But the problem is that it also show the seconds everywhere, which is abit annoing.
So can't I just fix this by doing some parsing in my Model? Something like this?
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;
        }

    }
}

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.

A:

Try to use 
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:MM/dd/yyyy}")]

It would works with EditorFor and DisplayFor helpers

A:

The solution for this got abit complicated since I had to get this to work with a Javascript Datetimepciker addon. (https://github.com/xdan/datetimepicker) And the format had to be very spesific.
So i ended up creating a helper method.
namespace MvcHtmlHelpers
{
    public static class MvcHtmlHelpers
    {
        public static string ToString(this DateTime inputDate, bool FixTime)
        {
            if (FixTime)
            {
                string returnString;

                if (inputDate == DateTime.MinValue)
                {
                    returnString = "N/A";
                }
                else
                {
                    returnString = inputDate.ToShortDateString() + ' ' + inputDate.ToShortTimeString();
                }
                return returnString;
            }
            return inputDate.ToString();
        }
    }
}

My form has one "viewing stage" and one "edit-mode stage" which is controlled by a edit button.
And I am overlaoding the .Value.ToString(true) method to use the helper method to format the date correctly.
<section class="col col-4">
    <label class="label">@Html.DisplayNameFor(model => model.Downtime_start)</label>
    <label class="input edit-case">
        <i class="icon-append fa fa-calendar"></i>
        <input type="text" id="Downtime_start" value="@Model.Downtime_start.Value.ToString(true)">
    </label>
    <label class="input state-disabled view-case">
        <i class="icon-append fa fa-calendar"></i>
        <input type="text" id="lbl_Downtime_start" disabled="disabled" value="@Model.Downtime_start.Value.ToString(true)">
    </label>
</section>

