The input type datetime-local
does not support setting and getting the value of the input as a Date
object, while it does support setting and getting the value as a number (epoch seconds).
// inputElement = <input type="datatime-local"> inputElement.valueAsDate = new Date(someDateString); // DOMException: Failed to set the 'valueAsDate' property on 'HTMLInputElement': This input element does not support Date values. inputElement.valueAsNumber = new Date(someDateString).valueOf();
This doesn't seem consistent, since the input types date
, time
, week
and month
do support both:
// inputElement = <input type="date"> inputElement.valueAsDate = new Date(someDateString); inputElement.valueAsNumber = new Date(someDateString).valueOf();
I would like to request some information to be added to the spec on why this feature isn't supported by this input type. But ideally I would prefer the following gets added to the spec for the datetime-local
input type:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4