I wrote the following code in JS
var d = new Date(2019, 9, 14);
var currentTime = d.getTime();
var daysToAdd = 3;
var secondsInDay = 86400;
var d = new Date(currentTime + daysToAdd*secondsInDay);
var year = d.getFullYear();
var month = ("0" + (d.getMonth())).slice(-2);
var day = ("0" + d.getDate()).slice(-2);
console.log('result in Y-M-D is: ' + year + '-' + month + '-' + day);
This outputs to result in Y-M-D is: 2019-09-14
What am I doing wrong here? How to I change this to output result in Y-M-D is: 2019-09-17 , which I originally intended to do
daysToAdd*secondsInDay*1000Check the details developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…new Date(2019, 9, 14)- this, as you know is actually, 14th October 2019 - however, the output string you want to create is2019-09-17- which would imply 17th September 2019 - perhaps not what you intended