I'm trying to set two dates into two different HTML date inputs. One for today and one for 30 days in the future. Here is my code:
function SetDate(date, dest){
var dd = String(date.getDate()).padStart(2, '0');
var mm = String(date.getMonth() + 1).padStart(2, '0');
var yyyy = date.getFullYear();
document.getElementById(dest).value = yyyy + '-' + mm + '-' + dd;
}
const date = new Date();
SetDate(date, 'sent');
SetDate(date.setDate(date.getDate() + 30), 'due');
This works for today's date and set's the correct date into the first HTML input, however, when it tries to set the second date 30 days in advance I get this error
Uncaught TypeError: date.getDate is not a function ... myscript.js:2
I just can't seem to figure out what the problem is.