我想要一个这样的新约会
var d = new Date();
var currentYear = d.getFullYear();
var christmasDate = new Date(Date.UTC(currentYear, 11, 25));
else if (tds[l].textContent === "26" && new Date() == christmasDate) {
var boxing_day = document.getElementById("boxing-day");
boxing_day.style.backgroundColor = "red";
var txt3 = "\r\nBoxing Day";
tds[l].textContent += txt3;
tds[l].classList.add("boxing-day-style");
tds[l].setAttribute("style", "white-space: pre; background: red; font-size: 20px; padding: 0; margin: 0; width: 15%; height: 15vh;");
}
,但它返回无效日期。任何帮助,将不胜感激。谢谢!
答案 0 :(得分:0)
简单的错误?
(new Date()).getFullYear()
// returns the current year
所以您的代码应该是:
var d = new Date();
var currentYear = d.getUTCFullYear();