cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

Add due date (15 days from schedule date)

Jump to solution

I have the following javascript and it only adds day and does not change month. Anything wrong with the code?

For example, this example I am using the current date.

The due date is showing 5/8/2017 instead of 6/8/2017 

May 25 2017 - Updated the following code by adding +1 with getMonth(). The code is now working.

var date = new Date();
date.setDate(date.getDate() + 15);
var control = NWF$("#"+ jsDueDate);
if(control.val() == "")
{
control.val(date.getMonth()+1 + "/" + date.getDate() + "/" + date.getFullYear());
}

Labels: (1)
0 Kudos
Reply
1 Reply
Workflow Hero

Re: Add due date (15 days from schedule date)

Jump to solution

it's because getMonth() returns zero based value.

ie. January == 0

so you have to use date.getMonth()+1

Reply