I'm not very familiar with JavaScript but I want to create a script that will pull the every single day of the week for me. Here is what I am working with right now.
I added the picture "Get date" and I would like to make it so that when I hit the "get date" button, it will go through the script and assign dates to the cells above Monday, Tuesday, Wednesday, etc. as 8/8, 8/9, 8/10.
I think you'll have to do it in two steps:
var date = new Date(), daysOfWeek = []; // find last Monday while(date.getDay() != 1) { date.setDate(date.getDate() - 1); } // build array of dates for(var n = 0; n < 7; n++) { daysOfWeek.push((date.getMonth() + 1) + '/' + date.getDate()); date.setDate(date.getDate() + 1); } console.log(daysOfWeek);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.