The following code works for most days. However, I'm having trouble with July 31, 2019.
var augDate = new Date('2019-08-19T00:00:00');
var julyDate = new Date('2019-07-31T00:00:00');
augDate.setMonth(augDate.getMonth() -1);
console.log(augDate.getMonth()); //retuns 6, good
console.log(julyDate.getMonth()); //returns 6
julyDate.setMonth(julyDate.getMonth() - 1); //try to get it to be 5, but it's still
console.log(julyDate.getMonth()); //still returns 6. I'm expecting 5
console.log(augDate);
console.log(julyDate);
For some reason the for July 31, the getMonth() - 1 doesn't change the date.