My JS code is currently as follows:
var today = new Date(),
d = today.getDate(),
m = today.getMonth() + 1,
y = today.getFullYear(),
date = d + '/' + m + '/' + y,
specialDate = '22/10/2012';
if (date == specialDate) {
document.getElementById("doodle").style.display = "block";
document.getElementById("defaultheader").style.display = "none";
}
else {
document.getElementById("doodle").style.display = "none";
document.getElementById("defaultheader").style.display = "block";
}
The code works perfectly but I’d now like to display #doodle for a week (22nd – 28th October) instead of one day. How do I do that?
It will be better to use
Date.now()ornew Date().getTime()to do this. Then you can compare two ‘times’:EDIT:
You also can create
dateFromanddateToin your console and put numeric values there – if you need to optimize it.