如果时间在范围内,我已经能够显示/隐藏按钮,但是,我如何修改它以检查日期是否是从 12 月 1 日开始的每个第二个星期二?
<p id="newButton">LIVE</p>
window.addEventListener("load", function(){
var newButton = document.getElementById("newButton");
const start = 12 * 60 + 30;
const end = 13 * 60 + 30;
const date = new Date();
const now = date.getHours() * 60 + date.getMinutes();
if(start <= now && now <= end) {
newButton.style.display = "block";
alert("in time");
}
else {
newButton.style.display = "none";
alert("offline");
}
}, false);
沧海一幻觉
相关分类