Line 2: Line 2:
 
datetime-local
 
datetime-local
 
===Type===
 
===Type===
_input
+
input
 
===Synopsis===
 
===Synopsis===
 
How to render a date and time input field  
 
How to render a date and time input field  
 
===Description===
 
===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.
+
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.
 
The format of the date and time value used by this input type is YYYY-MM-DDThh:mm.
Line 16: Line 16:
 
<syntaxhighlight lang="html">
 
<syntaxhighlight lang="html">
 
<_label for="meeting-time">Choose a time for your appointment:</_label>
 
<_label for="meeting-time">Choose a time for your appointment:</_label>
<_input type="datetime-local" id="meeting-time"
+
<input type="datetime-local" id="meeting-time"
 
       name="meeting-time" value="2022-03-01T10:00"
 
       name="meeting-time" value="2022-03-01T10:00"
 
   min="2022-03-01T10:00" max="2022-03-01T18:00" />
 
   min="2022-03-01T10:00" max="2022-03-01T18:00" />
 
</syntaxhighlight>
 
</syntaxhighlight>
<_label for="meeting-time">Choose a time for your appointment:</_label>
+
<label for="meeting-time">Choose a time for your appointment:</label>
<_input type="datetime-local" id="meeting-time"
+
<input type="datetime-local" id="meeting-time"
 
       name="meeting-time" value="2022-03-01T10:00"
 
       name="meeting-time" value="2022-03-01T10:00"
 
   min="2022-03-01T10:00" max="2022-03-01T18:00" />
 
   min="2022-03-01T10:00" max="2022-03-01T18:00" />

Revision as of 21:53, 13 December 2022

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