title: Storing an array of dates for the previous week in Javascript, getDate
body: <p>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.</p>
  
  <p>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.</p>
  
  <pre><code>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&lt;NumFields;i++) {
          $('.graph').append("&lt;div class=\"bar\"&gt;&lt;/div&gt;");
      }
  
      $('.graph &gt; .bar').each(function() {
          var currentData = data[index];
          $(this).attr('value', currentData);
          bars.push(currentData);
          date.push(now.getDate() - index);
          index++;        
      });
  </code></pre>
  
  <p>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."</p>
  
  <p>Thanks for your help! I'm super confused, and this is the first problem that has stumped me enough to require asking for help...</p>