Name

datetime-local

Type

_input

Synopsis

How to render a date and time input field

Description

_input elements of type datetime-local create input controls that let the user easily enter both a date and a time, including the year, month, and day as well as the time in hours and minutes.

The format of the date and time value used by this input type is YYYY-MM-DDThh:mm.

Parameters

type="datetime-local"

All other valid parameters for an input field are valid. Additionally you can use min, max and step.

Example

<_label for="meeting-time">Choose a time for your appointment:</_label>
<_input type="datetime-local" id="meeting-time"
       name="meeting-time" value="2022-03-01T10:00"
  min="2022-03-01T10:00" max="2022-03-01T18:00" />

Note

The displayed date and time formats differ from the actual value; the displayed date and time are formatted according to the user's locale as reported by their operating system, whereas the date/time value is always formatted YYYY-MM-DDThh:mm.

For more information on this input type, see the link below.

Links

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local