<input> - datetime-local


HTML DOM Input DatetimeLocal object


Input DatetimeLocal object

The Input DatetimeLocal object is new in HTML5.

Input DatetimeLocal objects represent HTML <input> elements with type="datetime-local".

Note: The <input> element is not supported by Internet Explorer or Firefox browsers.

Access the Input DatetimeLocal object

You can use the getElementById() function to access <input> elements with the type="datetime-local" attribute:

var x = document.getElementById("myLocalDate");

Try It! 

Tip: You can also access the Input DatetimeLocal object through the form's elements collection.

Create an Input DatetimeLocal object

You can use the document.createElement() method to create <input> elements with the type="datetime-local" attribute:

var x = document.createElement("INPUT");
x.setAttribute("type", "datetime-local");

Try It! 

Input DatetimeLocal Object Attributes

AttributeDescription
autocompleteSets or returns the value of the autocomplete property of the local time field
autofocusSets or returns whether the Local Time field automatically gets the focus after the page loads
defaultValueSets or returns the default value for the local time field
disabledSets or returns whether the Local Time field is available
formReturns a reference to a form that uses a local time field
listReturns a datalist reference that contains a local time field
maxSets or returns the value of the max property of the local time field
minSets or returns the min property value of the local time field
nameSets or returns the value of the name property of the local time field
readOnlySets or returns whether the Local Time field is read-only
requiredSets or returns whether the Local Time field is required in the form
stepSets or returns the value of the step property of the local time field
typeReturns the form element type for the local time field
valueSets or returns the value of the value property of the local time field

Standard Properties and Events

Input DatetimeLocal objects also support standard properties and events .


Related articles

HTML Tutorial: HTML Forms

HTML Reference Manual: HTML <input> Tag

HTML Reference Manual: HTML <input> type attribute