Hoe to set up a value, to input type = time , set in html using value attribute value.
I have tried:
var tm = new Date();
var in= "<input type='time' name='time' id='tm' value='" + tm + "'/>";
it does not work
If you want the time with AM & PM, check the first two values, and utilize something like the following: if(FirstTwoNums > 12){ FirstTwoNums -= 12; PM = true;}/*else, PM is false */ .
The <input type="time"> defines a control for entering a time (no time zone).
Use the valueAsDate attribute to convert between a Date
object and an input element’s value.
> var elem = document.createElement('input');
> elem.type = 'time';
> elem.valueAsDate = new Date(1970, 1, 1, 7, 34);
> elem.value
"12:34"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With