感谢所有人的贬低... var date = new Date(year, month, day, hours, minutes, seconds, milliseconds); doesn't work!
新问题:如何将div内的文本更改为true或false? 代码:
function getDate() {
var today = new Date();
var year = today.getFullYear();
var month = today.getMonth()+1;
var day = today.getDate();
var hours = today.getHours();
var minutes = today.getMinutes();
var seconds = today.getSeconds();
var milliseconds = today.getMilliseconds();
var date = new Date(year, month, day, hours, minutes, seconds, milliseconds);
var date2 = new Date(2014,11,1,22,00,00);
if (date === date2) {
document.getElementById("test").innerHTML = "true";
}
else
{
document.getElementById("false").innerHTML = "false";
}
}
由于某种原因,这不起作用:(,是的,div已经测试为id -Bram
答案 0 :(得分:2)
请先阅读一些文档:http://www.w3schools.com/js/js_dates.asp
var date = new Date(year, month, day, hours, minutes, seconds, milliseconds);