HTML <input> Tag with 'type=date'

<form name="myForm" action="http://www.htmlcodes.ws/resources/html-forms-action.cfm">
	
<input type="date" name="myDateField">

<button>Submit</button>
</form>

The above example demonstrates usage of the <input> element with the type attribute set to date (i.e. type="date").

The date value represents a control for setting the element's value to a string representing a specific date. This is a date (year, month, day) with no time zone.

Specifying a min and/or max Date

The min and max attributes can be used with dates to specify a minimum and maximum date. If specified, they must have a value that is a valid date string.

The following example specifies a min date of 3 days ago and a max date of 3 days time. Therefore the user can only select dates that fall within that range.

<form name="myForm2" action="http://www.htmlcodes.ws/resources/html-forms-action.cfm">
	
<input type="date" min="2017-08-19" max="2017-08-25" name="myDateField2">

<button>Submit</button>
</form>

Specifying a step

You can also use the step attribute to limit the number of days the user can choose from.

The following example uses a step value of 3 days, meaning the user can only select one date in every three days.

<form name="myForm3" action="http://www.htmlcodes.ws/resources/html-forms-action.cfm">
	
<input type="date" step="3" name="myDateField3">

<button>Submit</button>
</form>

You can also use the datetime, time, week, and month values when working with dates and times.