I have an LF Form that allows a date in a box. Then I have a date that is supposed to add a week from whatever the date happens to be in the first box. For testing purposes I always had the first box to the current date. I then followed a tutorial and just added 7 days to the current date.
Today I found out that with the script that I have, if today was '2017-06-24' then the next week box is set to '2017-06-31', but there are only 30 days in June. This isn't just incrementing because if I add 8 days instead of 7, it goes to '2017-07-01'. Any ideas on how to adjust the code below?
// Raul - Add a week // This is the "VERIFY" process var datePlusOneWeek = new Date(); datePlusOneWeek.setDate(datePlusOneWeek.getDate() + 7); //+ 7 makes june and september 31 days var dd_datePlusOneWeek = datePlusOneWeek.getDate(); //var dd_datePlusOneWeek = ('0' + (datePlusOneWeek.getDate()+parseInt(tSpan)+1)).slice(-2); //Working on this var mm_datePlusOneWeek = ('0' + (datePlusOneWeek.getMonth()+parseInt(tSpan)+1)).slice(-2); //January is 0! -----// month with leading zeros ('0' + (MyDate.getMonth()+1)).slice(-2) var yyyy_datePlusOneWeek = datePlusOneWeek.getFullYear(); var Rerformatted_datePlusOneWeek = yyyy_datePlusOneWeek+'-'+mm_datePlusOneWeek+'-'+dd_datePlusOneWeek; $(".DateToVerify input").val(Rerformatted_datePlusOneWeek); // Raul - Add a week // This is the "VERIFY" process