What I'm trying to do is build an array that contains the date of the prior 7 days. The code below does this for me. However, when (now.getDate() - index) is less than one, it doesn't jump the date back to the previous month, it simply brings the value negative.
I tried replacing that with (now.setDate(now.getDate() - index)) hoping to fix it, but I seem to be getting a UNIX time, and definitely not the correct one.
var bars = new Array();
var index = 0;
var NumFields = data.length - 2;
var now = new Date();
var date = new Array();
for(var i=0;i<NumFields;i++) {
$('.graph').append("<div class=\"bar\"></div>");
}
$('.graph > .bar').each(function() {
var currentData = data[index];
$(this).attr('value', currentData);
bars.push(currentData);
date.push(now.getDate() - index);
index++;
});
If you want to see the problem (remember, it won't look broken because the current date minus seven days is greater than zero), then go to habitic.com and click on "Running."
Thanks for your help! I'm super confused, and this is the first problem that has stumped me enough to require asking for help...