Reputation: 63
@Html.EditorFor(m => m.DateOfAcception, new
{
htmlAttributes = new { type = "datetime-local", required = "required" },
@class = "form-control datepicker",
@value = DateTime.Now.ToString()
})
I got something like that but the Value is not working also my model is
public DateTime DateOfAcception { get; set; } = DateTime.Now;
But i cant get it to start with default value.
This is how it looks in html
The part Novo is just @Html.EditorFor(m => m.DateOfAcception)
if the left side part can start with that value like that somehow
Upvotes: 4
Views: 4648
Reputation: 2917
You should use TextBoxFor and put international time and then Razor will convert it to local date time. I hope this will answer your question.
@Html.TextBoxFor(x => x.DateOfAcception, "{0:yyyy-MM-ddTHH:mm:ss}", new
{
@class = "form-control",
required = "required",
@type = "datetime-local"
})
Upvotes: 11