This is multiple questions in one.
Input type date is not supported by all browsers in use, so a fallback option is required for those cases. Where date inputs are supported, the value is returned as a string in yyyy-mm-dd format. By default, that is parsed as UTC however most want it to be treated as local so that needs to handled too.
The value from a time input is returned in hh:mm:ss format, so that also needs to be parsed to some usable form.
The trivial answer is to just join the date and time values with a "T" (producing a format of yyy-mm-ddThh:mm:ss) and leave it to the built–in parser as it should be parsed as local, but may not be (see Why does Date.parse give incorrect results?)
A more robust solution is to parse the date and time separately, then combine the values. You can use a library, but simple functions are only a couple of lines.
The following demonstrates both methods, hopefully the comments are sufficient.
// Parse yyyy-mm-dd as local
function parseISOLocal(s) {
let [y, m, d] = s.split(/\D/);
return new Date(y, m-1, d);
}
// Parse hh:mm:ss to ms
function parseTime(t) {
let [h, m, s] = t.split(/\D/);
return h*3.6e6 + m*6e4 + s*1e3;
}
// Create Date from combined date and time inputs
function getDate() {
// Get date string, parse as local
let d = parseISOLocal(document.getElementById('date').value);
// Get time, convert to milliseconds
let t = parseTime(document.getElementById('time').value);
// Add time to date
d.setMilliseconds(d.getMilliseconds() + t);
// Debug
console.log(d.toString());
// Return date
return d;
}
// Create date by concatenating date and time and
// using built-in parser
function getDate2(){
// Get date string
let d = document.getElementById('date').value;
// Get time string
let t = document.getElementById('time').value;
// Debug
console.log(new Date(d + 'T' + t).toString());
// Join with T and use built-in parser
return new Date(d + 'T' + t);
}
<input name="date" type="date" id="date" value="2020-12-12">
<input name="time" type="time" id="time" value="12:12:12">
<br>
<button onclick="getDate()">Get date manual parse</button>
<button onclick="getDate2()">Get date built-in parse</button>
There is also input type datetime (obsolete) and datetime-local, however support is lacking so not viable options.