title: Calculate number of days between two dates with momentsjs
body: <p>I got two dates stored inside a var (created by a date picker). To format these I am using <a href="http://momentjs.com/docs/" rel="nofollow">moments.js</a></p>
  
  <p>I want to calculate the number of days between these two fields and store this number inside a var <code>days</code>. This is my code so far:</p>
  
  <pre><code>// When someone clicks my submit button, I create an url stored in the var url.
  $(".book_submit").on('click', function(e){
  
    // I get the datepicker and input fields data
    var from = $('.from').val();
    var to = $('.to').val();
  
    // I can format the "from" var the way I want
    from  = moment(from, "DD.MM.YYYY");
    from = moment(from).format("YYYY-MM-DD");
  
    // I can format the "to" var the way I want
    to = moment(to, "DD.MM.YYYY");
    to = moment(to).format("YYYY-MM-DD");
  
    // I want to store the number between the two dates in the var "days", to place it inside my link below. I have found ".diff(to, 'days') in the moments documentation.
  
    //days = from.diff(to, 'days');   // =1
  
    var url = "https://mycustomlink&amp;days= " + days + "";
  
  });
  </code></pre>
  
  <p>I can't get <code>from.diff(to, 'days')</code> to work and store it inside a variable. I have tried to set it like:</p>
  
  <pre><code>var days = from.diff(to, 'days');
  </code></pre>
  
  <p>How can I store the difference between these to days inside my var <code>days</code>? I appreciate any suggestion.</p>