มี Google Form ที่ต้องการตั้งเวลาเปิด/ปิดแบบอัตโนมัติ (เฉพาะวันทำการ) หรือจะตั้งให้เปิด/ปิดเฉพาะวันที่กำหนด ก็ทำได้สบาย ไปดูกันเล้ยยย
// Presented by BrilliantPy function setOpenAndCloseForm() { /*######################### Editable Start #########################*/ let formId = "1n3TH0K1rUgB8IaWdSf_1UADSks2B9DXxVC2-Fl0tXkA"; let openTime = "8:50"; let closeTime = "15:50"; let minTrigger = 10; // 1,5,10,15,30 let dayActive = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']; // let dayActive = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; /*######################### Editable End #########################*/ // Init let days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; let curDate = new Date(); let dayName = days[curDate.getDay()]; let date = Utilities.formatDate(curDate, "GMT+7", "dd/MM/YYYY HH:mm") let hour = parseInt(Utilities.formatDate(curDate, "GMT+7", "H")); // let min = parseInt(Utilities.formatDate(curDate, "GMT+7", "mm")); let openHourS = parseInt(openTime.split(":")[0]); let openMinS = parseInt(openTime.split(":")[1]); let closeHourS = parseInt(closeTime.split(":")[0]); let closeMinS = parseInt(closeTime.split(":")[1]); const dateOpen = new Date(2018, 11, 24, openHourS, openMinS, 0); const dateClose = new Date(2018, 11, 24, closeHourS, closeMinS, 0); let factor = minTrigger*3; dateOpen.setMinutes(dateOpen.getMinutes()+factor); dateClose.setMinutes(dateClose.getMinutes()+factor); let openHourE = parseInt(Utilities.formatDate(dateOpen, "GMT+7", "H")); // let openMinE = parseInt(Utilities.formatDate(dateOpen, "GMT+7", "mm")); let closeHourE = parseInt(Utilities.formatDate(dateClose, "GMT+7", "H")); // let closeMinE = parseInt(Utilities.formatDate(dateClose, "GMT+7", "mm")); if (checkDayActive()) { if (hour >= openHourS && hour <= openHourE) { setForm("open"); } else if (hour >= closeHourS && hour <= closeHourE) { setForm("close"); } } function setForm(mode) { let form = FormApp.openById(formId); if (mode == "open") { form.setAcceptingResponses(true); console.log("Form open:",date) } else if (mode == "close") { form.setAcceptingResponses(false); console.log("Form close:",date) } } function checkDayActive() { for (let x of dayActive) { if (dayName == x) { return true; } } return false; } }
I am impressed with this website , very I am a fan.
Thank you. You can follow us either way.
youtube : https://www.youtube.com/@brilliantpy/videos
Facebook: https://web.facebook.com/BrilliantPy
Can I simply say what a reduction to search out somebody who really knows what theyre speaking about on the internet. You definitely know find out how to deliver a problem to light and make it important. More folks must read this and perceive this aspect of the story. I cant believe youre not more popular since you positively have the gift.
Thank you. You can follow us either way.
youtube : https://www.youtube.com/@brilliantpy/videos
Facebook: https://web.facebook.com/BrilliantPy
I genuinely enjoy looking at on this internet site, it contains wonderful blog posts.
Thank you. You can follow us either way.
youtube : https://www.youtube.com/@brilliantpy/videos
Facebook: https://web.facebook.com/BrilliantPy
Very nice post. I just stumbled upon your blog and wished to mention that I have really enjoyed browsing your blog posts. In any case I’ll be subscribing to your feed and I am hoping you write again very soon!
Thank you. You can follow us either way.
youtube : https://www.youtube.com/@brilliantpy/videos
Facebook: https://web.facebook.com/BrilliantPy
In this great scheme of things you actually receive an A+ for hard work. Where exactly you lost us was first on all the facts. You know, they say, details make or break the argument.. And that couldn’t be more true in this article. Having said that, allow me inform you just what exactly did work. The article (parts of it) can be rather engaging and that is probably the reason why I am making the effort to opine. I do not really make it a regular habit of doing that. Next, despite the fact that I can notice the jumps in logic you make, I am not really certain of exactly how you seem to connect the ideas which in turn make the actual conclusion. For the moment I shall subscribe to your point but wish in the foreseeable future you actually link the dots much better.
Thank you. You can follow us either way.
youtube : https://www.youtube.com/@brilliantpy/videos
Facebook: https://web.facebook.com/BrilliantPy
Thank you for another fantastic article. Where else could anybody get that type of information in such an ideal way of writing? I’ve a presentation next week, and I’m on the look for such information.
Thank you. You can follow us either way.
youtube : https://www.youtube.com/@brilliantpy/videos
Facebook: https://web.facebook.com/BrilliantPy