Input DatetimeLocal value Attribute
Definition and Usage
value
Sets or returns the value of the value attribute of the local date-time field.
HTML value attribute specifies the local date and time for the local date-time field.
See Also:
HTML Reference Manual:HTML <input> value Attribute
Instance
Example 1
Set the local date and time of the date-time field:
document.getElementById("myLocalDate").value = "2023-02-15T18:15:30.520";
Example 2
Get the local date and time of the date-time field:
var x = document.getElementById("myLocalDate").value;
Example 3
An example showing the difference between defaultValue and value attributes:
var x = document.getElementById("myLocalDate"); var defaultVal = x.defaultValue; var currentVal = x.value;
Syntax
Return value attribute:
datetimelocalObject.value
Set value attribute:
datetimelocalObject.value = YYYY-MM-DDThh:mm:ss.ms
Attribute Value
Value | Description |
---|---|
YYYY-MM-DDThh:mm:ss.ms |
Specify the date and time. Component Description:
|
Technical Details
Return Value: | A string value representing the date and time of the local date and 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-local"> element does not display any date and time fields/calendars in Firefox.