Reputation: 337
I've looked at other questions on this, but for some reason I can't get it to work.
I have an array which my code loops through, and part of the array it needs to add a day to one of the dates. my code (with loggers to show the data) looks like this:
Logger.log('source array - ' + sourceArray[i][8])
var deliveryDate = new Date(sourceArray[i][8])
Logger.log ('deliveryDate - ' + deliveryDate)
var newDate = new Date(deliveryDate + 1000*60*60*24)
Logger.log ('newDate - ' + newDate)
There's more to my application but this is where I'm having issues.
This is a screenshot of the log
As you can see the data from the source array has a date of 8th march 2023
So does the deliveryDate variable that I assign the data to.
But after adding to it (I read to use that multiplication to add a day) newDate is still the same.
I can't figure out where my syntax is wrong.
Upvotes: 0
Views: 35
Reputation: 64140
Try this:
function addADay(dt = new Date()) {
dt.setDate(dt.getDate() + 1);
Logger.log(dt);
}
Upvotes: 0