Example
Set a local date and time for a datetime field:
document.getElementById("myLocalDate").value = "2014-01-02T11:42:13.510";
Try it Yourself »
Definition and Usage
The value property sets or returns the value of the value attribute of a local datetime field.
The value attribute specifies a local date and time for the datetime field.
Browser Support
Property | |||||
---|---|---|---|---|---|
value | Yes | 10.0 | Yes | Yes | Yes |
Note: The <input type="datetime-local"> element does not show any datetime field/calendar in Firefox.
Syntax
Return the value property:
datetimelocalObject.value
Set the value property:
datetimelocalObject.value=YYYY-MM-DDThh:mm:ss.ms
Property Values
Value | Description |
---|---|
YYYY-MM-DDThh:mm:ss.ms |
Specifies the date and time. Explanation of components:
|
Technical Details
Return Value: | A String, representing the date and time of the local datetime field |
---|
More Examples
Example
Get the local date and time of a datetime field:
var x = document.getElementById("myLocalDate").value;
The result of x will be:
2014-11-16T15:25:33
Try it Yourself »
Example
An example that shows the difference between the defaultValue and value property:
var x = document.getElementById("myLocalDate");
var defaultVal =
x.defaultValue;
var currentVal = x.value;
Try it Yourself »
Related Pages
HTML reference: HTML <input> value attribute
< Input DatetimeLocal Object