I found the following code on this site and it works great for what I am trying to do. The only thing I can't figure out is how to format the dates that are outputting.
The variable that I am specifically looking at formatting is the nextq
variable. Currently it outputs like Tue Oct 01 2019 00:00:00 GMT-0400 (Eastern Daylight Time)
.
I am wanting to simplify this to where it would say "Tuesday (Tues is fine), Oct 01, 2019 - with no time. Alternatively, Tues, 10/01/19. Either one would work.
How would I do this when the date is already formatted?
var today = new Date();
var quarter = Math.floor((today.getMonth() + 3) / 3);
var nextq;
if (quarter == 4) {
nextq = new Date (today.getFullYear() + 1, 1, 1);
} else {
nextq = new Date (today.getFullYear(), quarter * 3, 1);
}
var millis1 = today.getTime();
var millis2 = nextq.getTime();
var daydiff = (millis2 - millis1) / 1000 / 60 / 60 / 24;
console.log("Check2 " + daydiff);
daydiffRound = Math.floor(daydiff);
console.log("check2 round " + daydiffRound);
console.log("Check2 date " + nextq);