I am trying to create a small program for scheduling by day and hour, but I stumbled upon a snag - calculating the date does not work, unless specific values were initially specified, If, for example, the values come from the user after the function is executed:
var timeX = 1; var timeY = 1.5; var timeI = 4; function additionalTime() { var x = +document.getElementById('x').value; var y = +document.getElementById('y').value; var i = +document.getElementById('i').value; var aTime1 = timeX * x + timeY * y + timeI * i; document.getElementById('additionalTime1').value = aTime1; }; var now = new Date(); var tomorrow = new Date(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours() + additionalTime(), now.getMinutes()); As a result, console.log (tomorrow) issues an Invalid Date even after entering data. How can I fix this?