Date and Time controls in HTML5
There are several input types for date and time in HTML5. They are:
1. date Input Type: The date type is used
for valid date entry by the user. It checks for valid date entry by the user. Its
syntax is given below:
<input type="date">
Now we create a form with date input type by writing the following code:
- <!DOCTYPE HTML>
- <html>
- <body>
- <form method="post">
- Date
- <input type="date"/>
- <input type="submit" />
- </form>
- </body>
- </html>
Then we run this code. The output will look like
as below:

If the user does date entry in other YYYY/MM/DD format,
then after Clicking submit button it shows message like as following figure:

2. time Input Type: The time input type is
used for valid time entry. It accepts the input in a 24-hour time format. Its
syntax is given below:
<input type="time">
Now we create a form with time input type by writing the following code:
- <!DOCTYPE HTML>
- <html>
- <body>
- <form method="post">
- Time
- <input type="time"/>
- <input type="submit" />
- </form>
- </body>
- </html>

If the user does time entry other
than HH: MM format, then after Clicking submit button it shows a message like as
following figure:

Join the conversation! Your thoughts help the community grow.