HTML DOM Input Datetime Object
- Previous Page <input> date
- Next Page <input> datetime-local
Datetime Object
The Datetime object is a new object in HTML5.
The Datetime object represents the HTML <input type="datetime"> element.
Note:Internet Explorer, Firefox, or Chrome do not support the <input type="datetime"> element, Safari supports some of them. Opera 12 and earlier versions fully support it.
Access Datetime Object
You can access the <input type="myDatetime"> element by using getElementById():
var x = document.getElementById("myDatetime");
Tip:You can also traverse the form's elements collectionto access the Datetime object.
Create Datetime Object
You can create an <input type="datetime"> element by using the document.createElement() method:
var x = document.createElement("INPUT"); x.setAttribute("type", "datetime");
Datetime Object Properties
Attributes | Description |
---|---|
autocomplete | Set or return the autocomplete attribute value of the datetime field. |
autofocus | Set or return whether the datetime field should automatically focus after page loading. |
defaultValue | Set or return the default value of the datetime field. |
disabled | Set or return whether the datetime field is disabled. |
form | Return a reference to the form containing the datetime field. |
list | Return a reference to the datalist containing the datetime field. |
max | Set or return the max attribute value of the datetime field. |
min | Set or return the min attribute value of the datetime field. |
name | Set or return the name attribute value of the datetime field. |
readOnly | Set or return whether the datetime field is read-only. |
required | Set or return whether the datetime field must be filled out before submitting the form. |
step | Set or return the step attribute value of the datetime field. |
type | Return the form element type of the datetime field. |
value | Set or return the value of the datetime field's value attribute. |
Input Datetime Object Methods
Method | Description |
---|---|
select() | Select the content of the datetime text field. |
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 Attributes and Events
Datetime Object Supports StandardsAttributesAndEvents.
Related Pages
HTML Tutorial:HTML Forms
HTML Reference Manual:HTML <input> tag
HTML Reference Manual:HTML <input> type attribute
- Previous Page <input> date
- Next Page <input> datetime-local