JoBo
JoBo

Reputation: 347

Todays datetime in asp-for helper MVC razor

I'm trying to get todays datetime (YYYY-MM-DD) to show up as default in my box where I choose date. Any ideas what I can do to show the MAX part as todays date by default. Guess I can create a variable and set it to today's date and use it but are there any easier way, like I'm trying to do it with a max="something"??

 <input type="date" asp-for="MovingAverageViewModel.StartDate" id="StartDateAnvanceradSMA" value="MovingAverageViewModel.StartDate" class="form-control" max="DateTime.Now.ToShortDateString();" min="2017-01-01" />

Upvotes: 0

Views: 2954

Answers (1)

JoBo
JoBo

Reputation: 347

Thanks Stephen, the answer: max="@DateTime.Today.ToString("yyyy-MM-dd")"

Upvotes: 4

Related Questions