What is "datetime-local"

The datetime-local is a type of input HTML to represent a date and time, which replaces the type datetime (now considered obsolete and unsupported by browsers).

This kind of input is similar to types date and time, and allows the user to enter the date and time (day, month, year, hour and minute). One thing to note is that seconds are not supported, unlike the type time, that allows the input of the seconds field.

An example of this type of use:

<input type="datetime-local" id="meeting-time"
       name="meeting-time" value="2018-06-12T19:30"
       min="2018-06-07T00:00" max="2018-06-14T00:00">

The way this is rendered depends on the browser. Some may show controls to increment or decrement the fields, taking care to always keep them within the allowed limits (days between 01 and 31, for example, beyond the maximum and minimum values indicated by the attributes max and min). If the browser no support this type is usually shown as a common text field, and the documentation suggests alternatives to deal with these cases.

The value of a field datetime-local will always be the date and time on ISO 8601 format, i.e.: "year-month-day", followed by the letter T, followed by "hour:minute" (seconds are omitted in this case because their value is zero). In the example above, for example, the initial value is 2018-06-12T19:30.

This field does not support timezones (time zones) and these should be treated separately, as recommended by the documentation.