How to check future date by comparing today's formatted date in javaScript? The needed variable is commented in the below code.
var formattedDate = new Date();
var d = formattedDate.getDate();
var m = formattedDate.getMonth();
m += 1;
var tomorrowDay = d + 1;
var y = formattedDate.getFullYear();
var todayDate = y + "-" + m + "-" + d;
var tomorrowDate = y + "-" + m + "-" + tomorrowDay;
var futureDate = ??? //Logic Needed
if (this.data) {
var Items = this.data.itemCollectionData;
for (var i = 0; i < dealItems.length; i++) {
if (Items[i].showDate == todayDate) {
Items[i].isToday = true;
} else if (Items[i].showDate == tomorrowDate) {
Items[i].isTomorrow = true;
} else if (Items[i].showDate == futureDate) {
Items[i].isFutureDate = true;
}
}
}
futureDate may be any day after tomorrow, it may be next year or next month. Tomorrow logic needs a correction too because it will not work on the last day of the month. Items[i].showDate always comes as a string in this format yyyy-mm-dd.