Embarrassingly enough I need a small algorithm
I am helping with a site where gif B is shown on the first of July, C on the third and A on the fifth. Then b again on the seventh and so on – a,b,c changing every second day at 8 in the morning
So how do I use a simple algo to make this script return 0, 1 or 2 depending on how many days since the 1st of July
http://jsfiddle.net/mplungjan/T2Tjh/
var startDate = new Date(2012,6,1,8,0,0);
var pics = ["b.gif","c.gif","a.gif"];
var aDay = 24*60*60*1000;
function getDateDiff(startDate,endDate) {
var diff = endDate.getTime() - startDate.getTime();
return Math.round(diff/aDay);
}
document.write('<br/>'+getDateDiff(startDate,new Date()));
Try this: