Nov 28, 2022
0
Level 7
Date function in Javascript
I want to get the week day from day in a month.
const lastDay = new Date(date.getFullYear(), date.getMonth()+1, 0).getDate();
let available_days = [2,3,5];
for(let i =1; i <= lastDay; i++){
let x = i % 7;
// i want to get the weekday from i which is the day
// let Array = [0,3,5];
if(available_days.indexOf(x) >= 0){
days += `<button style="padding:6px;" class="hover:bg-[#126376] hover:text-white transition duration-150 ease-in bg-[#BDF0FC] rounded-full">${i}</button>`;
} else {
days += `<button style="padding:6px;" class="bg-gray-400 rounded-full" disabled>${i}</button>`;
}
}
how can i get it. this is how it looks https://ibb.co/pfBNXKb
Please or to participate in this conversation.