Input time value [type = time]

Hoe set value, enter type = time, set in html using the value attribute value.

I tried:

var tm = new Date(); var in= "<input type='time' name='time' id='tm' value='" + tm + "'/>"; 

he does not work

+4
source share
1 answer

Use valueAsDate to convert between a Date object and the value of the input elements.

 > var elem = document.createElement('input'); > elem.type = 'time'; > elem.valueAsDate = new Date(1970, 1, 1, 7, 34); > elem.value "12:34" 
+5
source

Source: https://habr.com/ru/post/1482423/


All Articles