title: How to exclude weekends between two dates using Moment.js
body: <p>I am trying to exclude weekends in my JavaScript code. I use moment.js and having difficulty choosing the right variable for 'days'.</p>
  
  <p>So far I have thought that I need to exclude day 6 (saturday) and day 0 (sunday) by changing the weekday variable to count from day 1 to day 5 only. But not sure how it changes.</p>
  
  <p>My jsfiddle is shown here: <a href="http://jsfiddle.net/Xt2e6/"><strong>FIDDLE</strong></a></p>
  
  <p><strong>HTML</strong>:</p>
  
  <pre><code>&lt;div id="myContent"&gt;
  &lt;input type="radio" value="types" class="syncTypes" name="syncTypes"&gt; &lt;td&gt;&lt;label for="xshipping.xshipping1"&gt;Free Shipping: (&lt;span id="fsv1" value="5"&gt;5&lt;/span&gt; to &lt;span id="fsv2" value="10"&gt;10&lt;/span&gt; working days)&lt;/label&gt; &lt;/td&gt;&lt;br&gt;
      &lt;div id="contacts" style="display:none;border:1px #666 solid;padding:3px;top:15px;position:relative;margin-bottom:25px;"&gt;     
      Contacts
  &lt;/div&gt;
  &lt;input type="radio" value="groups" class="syncTypes" name="syncTypes"&gt; &lt;td&gt;&lt;label for="xshipping.xshipping2"&gt;Express Shipping: (&lt;span id="esv1" value="3"&gt;3&lt;/span&gt; to &lt;span id="esv2" value="4"&gt;4&lt;/span&gt; working days)&lt;/label&gt; &lt;/td&gt;    
  &lt;div id="groups" style="display:none;border:1px #666 solid;padding:3px;top:15px;position:relative"&gt;     
      Groups
  &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>JavaScript</strong>:</p>
  
  <pre><code>var a = 5; //Free shipping between a
  var b = 10;//and b
  var c = 3;//Express shipping between c
  var d = 4;//and d    
  var now = moment();    
  var f = "Your item will be delivered between " + now.add("days",a).format("Do MMMM") + " and " + now.add("days",b).format("Do MMMM");
  var g = "Your item will be delivered between " + now.add("days".c).format("Do MMMM") + " and " + now.add("days",d).format("Do MMMM");
  
  var h = document.getElementById('contacts');
  h.innerHTML = g
  
  var i = document.getElementById('groups');
  i.innerHTML = f
  
  $(function() {
      $types = $('.syncTypes');
      $contacts = $('#contacts');
      $groups = $('#groups');
      $types.change(function() {
          $this = $(this).val();
          if ($this == "types") {
              $groups.slideUp(300);
              $contacts.delay(200).slideDown(300);
          }
          else if ($this == "groups") {
              $contacts.slideUp(300);
              $groups.delay(200).slideDown(300);
          }
      });
  });
  </code></pre>