Input Datetime value attribute
Definition and Usage
value
Attribute settings or returns the value of the value attribute of the date-time field.
HTML value attribute specifies the date and time for the date-time field.
See Also:
HTML Reference Manual:HTML <input> value Attribute
Instance
Example 1
Set the date and time for the date-time field:
document.getElementById("myDatetime").value = "2014-01-02T11:42Z";
Example 2
Get the date and time of the date-time field:
var x = document.getElementById("myDatetime").value;
Syntax
Return the value attribute:
datetimeObject.value
Set the value attribute:
datetimeObject.value = YYYY-MM-DDThh:mm:ssTZD
Attribute Value
Value | Description |
---|---|
YYYY-MM-DDThh:mm:ssTZD |
Specify the date and/or time. Component Description:
|
Technical Details
Return Value: | A string value representing the date and time of the date-time field. |
---|
Browser Support
The numbers in the table indicate the first browser version that fully supports this attribute.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | 10.0 | Support | Support | Support |
Note:The <input type="datetime"> element does not display any date-time field/calendar in any mainstream browser except Safari.