I am trying to show some data within calendar dates. I giving it a start date and an end date. I only want it to show within those dates. I have been trying to do this but I cannot seem to make it work right. I thought I had it but was wrong.
var objData = [];
var month = [ "january","february","march", "april", "may", "june", "july", "august", "september", "October", "november", "december"];
var d = new Date( );
var currDate = d.getDate();
var currMonth = d.getMonth();
var currYear = d.getFullYear();
var currPromoIndex;
for (var i =0; i < obj.length; i++)
{
var start = obj[i].dateRange[0];
var end = obj[i].dateRange[1];
var promoStartMonth = start.slice( 0,2 ).replace("/", "");
var promoStartDay = start.slice( start.indexOf("/"), start.length ).replace("/", "");
var promoEndMonth = end.slice( 0,2 ).replace("/", "");
var promoEndDay = end.slice( end.indexOf("/"), end.length ).replace("/", "");
var myPromoStart = new Date( currYear, promoStartMonth-1, promoStartDay);
var myPromoEnd = new Date( currYear, promoEndMonth-1, promoEndDay);
if ( ( ( d > myPromoStart ) && ( d < myPromoEnd) ) || ( d >= myPromoEnd ) )
{
objData = obj[i];
console.log(obj[i]);
}
}
My Date Range is stored in a json and it looks like this.
"dateRange" : [ "4/13", "5/12" ],...
Im not sure how else to do this as I have tried many different ways and nothing seems to be working accordingly.