1

Please find the snippet with issues below

var date = new Date('9/14/2016');
alert((date.getMonth() + 1) + '/' + (date.getDate()+20) + '/' + date.getFullYear());

enter image description here

On adding 20 days from the current date, it should display expected result as shown in the above image. Currently, the inserted data is not parsed as Date format to get the exact output. any work around on this?

Prashanth Sams
  • 19,677
  • 20
  • 102
  • 125

1 Answers1

0

The following should work:

var date = new Date('12/14/2016'); 
date.setDate(date.getDate() + 20); // add 20 days 
alert((date.getMonth()+1) + '/' + (date.getDate()) + '/' + date.getFullYear()); // output
Prashanth Sams
  • 19,677
  • 20
  • 102
  • 125
JanW
  • 34
  • 6