HTML <input> Tag with 'type=date'

<form name="myForm" action="">
<input type="date" name="myDateField">


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="">
<input type="date" min="2024-05-23" max="2024-05-29" name="myDateField2">


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="">
<input type="date" step="3" name="myDateField3">


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