Set An HTML Date Input Value Using .NET

6/20/2015 11:25:37 PM

You can create a Date input field with the input tag in html (<input type="date" />). If you want to set this field to a value, use the format below. If you are using .NET MVC, you can set the value with the following code. 

<input type="date" value="2015-06-20">

Today's Date: <input type="date" name="todaysDate" value="@DateTime.Now.ToString("yyyy-MM-dd")" />

<!-- Output -->
<input type="date" name="todaysDate" value="2015-06-20" />