Input Datetime value Property
Example
Set a date and time for a datetime field:
document.getElementById("myDatetime").value = "2014-01-02T11:42Z";
Try it Yourself »
Definition and Usage
The value property sets or returns the value of the value attribute of a datetime field.
The value attribute specifies a date and time for the datetime field.
Browser Support
Property | |||||
---|---|---|---|---|---|
value | Yes | 10.0 | Yes | Yes | Yes |
Note: The <input type="datetime"> element does not show any datetime field/calendar in any major browsers, except Safari.
Syntax
Return the value property:
datetimeObject.value
Set the value property:
datetimeObject.value = YYYY-MM-DDThh:mm:ssTZD
Property Values
Value | Description |
---|---|
YYYY-MM-DDThh:mm:ssTZD |
Specifies the date and/or time. Explanation of components:
|
Technical Details
Return Value: | A String, representing the date and time of the datetime field |
---|
More Examples
Example
Get the date and time of a datetime field:
var x = document.getElementById("myDatetime").value;
Try it Yourself »
Related Pages
HTML reference: HTML <input> value attribute
❮ Input Datetime Object