title: Get a list of dates between two dates using javascript
body: <p>From JavaScript is there a way to get list of days between two dates from MySQL format. I don't want to use any library for this.
  This is what i did.</p>
  
  <pre><code>function generateDateList(from, to) {
  
      var getDate = function(date) { //Mysql Format
          var m = date.getMonth(), d = date.getDate();
          return date.getFullYear() + '-' + (m &lt; 10 ? '0' + m : m) + '-' + (d &lt; 10 ? '0' + d : d);
      }
      var fs = from.split('-'), startDate = new Date(fs[0], fs[1], fs[2]), result = [getDate(startDate)], start = startDate.getTime(), ts, end;
  
      if ( typeof to == 'undefined') {
          end = new Date().getTime();
      } else {
          ts = to.split('-');
          end = new Date(ts[0], ts[1], ts[2]).getTime();
      }
      while (start &lt; end) {
          start += 86400000;
          startDate.setTime(start);
          result.push(getDate(startDate));
      }
      return result;
  }
  
  console.log(generateDateList('2014-2-27', '2014-3-2'));
  </code></pre>
  
  <p>I test it from chrome and nodejs below are the result.</p>
  
  <pre><code>[ '2014-02-27',
    '2014-02-28',
    '2014-02-29',
    '2014-02-30',
    '2014-02-31',
    '2014-03-01',
    '2014-03-02' ]
  </code></pre>
  
  <p>yeh big leap year:-D..., how can i fix this? or is there any better way.?</p>