title: How can I make a date filter on boostrap table with javascript/momentJS
body: <p>I'm currently working with bootstrap table and I wanted to set up a date filter. The user input a start date and an end date with the following format : &quot;YYY-mm-dd HH:mm:ss&quot;. Then, the Bootstrap table shows all the data between the two dates.</p>
  <p><a href="https://i.stack.imgur.com/o4VbC.png" rel="nofollow noreferrer">Input img</a></p>
  <p><a href="https://i.stack.imgur.com/Bq0Xn.png" rel="nofollow noreferrer">result</a></p>
  <p>I saw this javascript code before but it doesn't work with the format I want.</p>
  <pre class="lang-js prettyprint-override"><code>$(function() 
    {
      $('#table').bootstrapTable()
    }
    )
    
  //Moment.JS Return Date Ranges
  function getDates(startDate, stopDate) {
      var dateArray = [];
      var currentDate = moment(startDate);
      var stopDate = moment(stopDate);
      while (currentDate &lt;= stopDate) {
          dateArray.push( moment(currentDate).format('YYYY-MM-DD'))
          currentDate = moment(currentDate).add(1, 'days');
      }
      return dateArray;
  }
   
    
    $('#ok').click( function() 
    { 
  
      var $table = $('#table')
      var from=$(&quot;input[type=date][name=date1]&quot; ).val();
      var to=$(&quot;input[type=date][name=date2]&quot; ).val();
      $table.bootstrapTable('filterBy',{ ETA: getDates(from,to)}) 
          
      
   
  })
  </code></pre>
  <p>HTML code</p>
  <pre class="lang-html prettyprint-override"><code>&lt;div id=&quot;toolbar&quot;&gt;
    &lt;div class=&quot;form-inline&quot; role=&quot;form&quot;&gt;
      &lt;div class=&quot;form-group&quot;&gt;
        &lt;span&gt;From Date &lt;/span&gt;
        &lt;input name=&quot;date1&quot; class=&quot;form-control w70&quot; type=&quot;date&quot; &gt;
      &lt;/div&gt;
      &lt;div class=&quot;form-group&quot;&gt;
        &lt;span&gt;To Date &lt;/span&gt;
        &lt;input name=&quot;date2&quot; class=&quot;form-control w70&quot; type=&quot;date&quot;&gt;
      &lt;/div&gt;
      &lt;button id=&quot;ok&quot; type=&quot;submit&quot; class=&quot;btn btn-primary&quot;&gt;OK&lt;/button&gt;
    &lt;/div&gt;
  &lt;/div&gt;    
  
  &lt;table id=&quot;table&quot; data-toggle=&quot;table&quot; data-toolbar=&quot;#toolbar&quot; &gt;
      &lt;thead&gt;
      &lt;tr&gt;
          &lt;th data-field=&quot;ETA&quot;&gt;Date&lt;/th&gt;
          &lt;th data-field=&quot;number&quot;&gt;Number&lt;/th&gt;
      &lt;/tr&gt;
      
      &lt;/thead&gt;
      &lt;tbody&gt;
      
      &lt;tr id=&quot;tr-id-1&quot; class=&quot;tr-class-1&quot;&gt;
          &lt;td id=&quot;td-id-1&quot; class=&quot;td-class-1&quot;&gt;2019-02-01 10:32:12&lt;/td&gt;
          &lt;td&gt;0&lt;/td&gt;
         &lt;/tr&gt;
         
          &lt;tr id=&quot;tr-id-2&quot; class=&quot;tr-class-2&quot;&gt;
          &lt;td id=&quot;td-id-2&quot; class=&quot;td-class-2&quot;&gt;2019-02-02 09:12:23&lt;/td&gt;
          &lt;td&gt;1&lt;/td&gt;
         &lt;/tr&gt;
         
          &lt;tr id=&quot;tr-id-3&quot; class=&quot;tr-class-3&quot;&gt;
          &lt;td id=&quot;td-id-3&quot; class=&quot;td-class-3&quot;&gt;2019-02-03 16:32:09&lt;/td&gt;
          &lt;td&gt;2&lt;/td&gt;
         &lt;/tr&gt;
  </code></pre>
  <p>Thanks you in advance</p>