Javascript generate a new date by adding time to get new date value

Viewed 15

Trying to generate an "expireDate" value with javascript, but get this error message

"Embedded message: [Function: Scripting]: Error executing custom script: TypeError: endDate.getDate is not a function in <eval> at line number 6; Caused by: TypeError: endDate.getDate is not a function in <eval> at line number 6; Caused by: TypeError: endDate.getDate is not a function"
  1. the input value from user is a startDate
  2. endDate is calculated to by adding 12 months (1 year) and the hours are removed

I was trying to add an additional value called expireDate that will include(startDate + 1yr + 30 days), but get an error

  • JavaScript code
    date = new Date(startDate);
    endDate = new Date(date.setMonth(date.getMonth()+12));
    Date(endDate.setHours(endDate.getHours()-24));
    endDate = endDate.toISOString().split("T")[0];
    expireDate = new Date () ;
    expireDate.setDate(endDate.getDate()+addDays); 

"addDays" value is a static value set to 30"

0 Answers
Related