i want to see if day is Saturday or Sunday, 0 or 6 using getDay()==1 and getday()==0, if it is dont add the date and time to my select option.
var from = new Date(firstNewDt);
var to = new Date(start);
var day = from.getDate();
if (from.getHours() <= 16 && from.getMinutes() <= 30 && from.getHours() >= 8 && from.getDay()==0||from.getDay()==1) {
if (day <= 9) {
day = "0" + day;
}
var month = from.getMonth() + 1;
if (month <= 9) {
month = "0" + month;
}
var year = from.getFullYear();
var hours = from.getHours();
if (hours < 10) {
hours = "0" + hours;
}
var minutes = from.getMinutes();
if (minutes < 30) {
minutes = "0" + minutes;
}
var dayto = to.getDate();
if (dayto <= 9) {
dayto = "0" + dayto;
}
var monthto = to.getMonth() + 1;
if (monthto <= 9) {
monthto = "0" + monthto;
}
var yearto = to.getFullYear();
var hoursto = to.getHours();
if (hoursto < 10) {
hoursto = "0" + hoursto;
}
var minutesto = to.getMinutes();
if (minutesto < 30) {
minutesto = "0" + minutesto;
}
bookedFreeTimes.push(year + "-" + month + "-" + day + " " + hours + ":" + minutes + " , " + yearto + "-" + monthto + "-" + dayto + " " + hoursto + ":" + minutesto);
}
}
Here is my code i add my values to an array and then display them.
Right now if i add the value 2014-12-10 12:00 to 2014-12-10 12:30
i then add days -5 from StartDate, and +5 days from Endate,
So i am quering from 2014-12-05 12:00 to 2014-12-15 12:30
so its should not display 6,7 dec, and 13,14 dec so right now it it dony display 6 dec and and 13 dec so its not displaying saturdays but sundays its displaying why?
UPDATE
=================
Should i have like this?
if (from.getHours() <= 16 && from.getMinutes() <= 30 && from.getHours() >= 8 && (from.getDay() == 0|| from.getDay() == 1))
Because like this it still displays 7, and 14 december