Creating a date from a previous date and adding to it
Hi I have a variable called myDate and it is set properly. If you care to see here is how I did it...
var myDate=new Date(); var ev_num = parseInt(document.getElementById("leave").value) myDate.setFullYear(sel_year.value,sel_month.value,sel_day.value);
I have another variable called first_number. I am trying to set it to myDate and simply add 31 days to it, but the date being displayed is incorrect. Here is my code for it. Can someone please help me fix it...
var first_number = new Date(); first_number.setDate(myDate.getDate() + 31);
I think you want to initialize first_number with the myDate, instead of creating a new (current) Date object. To do so, use
var first_number = new Date(myDate);