HTML DOM Input DatetimeLocal Object

Datetime Local object

The Datetime Local object is a new object in HTML5.

The Datetime Local object represents the HTML <colgroup> element.

Note:Internet Explorer or Firefox does not support the <input type="datetime-local"> element.

Access Datetime Local object

You can access the <datetime-local> element by using getElementById():

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

Try It Yourself

Tip:You can also iterate over the form's elements collectionto access the Input Date object.

Create Datetime Local object

You can create a <datetime-local> element by using the document.createElement() method:

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

Try It Yourself

Datetime Local object properties

Properties Description
autocomplete Set or return the autocomplete attribute value of the local time field.
autofocus Set or return whether the local time field should automatically focus after the page is loaded.
defaultValue Set or return the default value of the local time field.
disabled Set or return whether the local time field is disabled.
form Return a reference to the form containing the local time field.
list Return a reference to the datalist containing the local time field.
max Set or return the max attribute value of the local time field.
min Set or return the min attribute value of the local time field.
name Set or return the name attribute value of the local time field.
readOnly Set or return whether the local time field is read-only.
required Set or return whether the local time field must be filled out before submitting the form.
step Set or return the step attribute value of the local time field.
type Return the form element type of the local time field.
value Set or return the value of the local time field's value attribute.

Input DatetimeLocal object methods

Method Description
stepDown() Decrement the value of the datetime field by a specified number.
stepUp() Increment the value of the datetime field by a specified number.

Standard properties and events

The Datetime Local object supports standardsPropertiesAndEvents.

Related Pages

HTML Tutorial:HTML Forms

HTML Reference Manual:HTML <input> tag

HTML Reference Manual:HTML <input> type attribute