HTML and CSS Reference
Date and Time
The datetime type can be used to collect a date and time from a user. This date/time combo should be a valid
Coordinated Universal Time (UTC) string. UTC time is the standardized time used by computers.
Fortunately, specifying the datetime type will instruct the browser to display a date picker to help the users input
their date in the correct format. This usually takes the form of a small calendar. The time segment is inputted using a
text field with helper controls similar to those displayed with a number field. Figure 6-9 shows an example of a
datetime field with the date picker displayed.
Figure 6-9 An input element with the type datetime, as displayed in Opera.
Here is an example of an <input> element with the type datetime .
<input type="datetime" name="eventStart" id="eventStart">
There will be times when you just want to collect a date from your users; for example, you might want to collect
their date of birth. The date type is very useful for such occasions.
As you've probably already guessed, the date type is exactly the same as datetime, just without the time part.
Browsers that support the date type will still display a date picker to help the user easily select a date.
Here is an example of an <input> element with the type date .
<input type="date" name="dob" id="dob">