title: How to correctly increment or decrement the day in a date?
body: <p>I'm trying to set in Javascript as data attribute to a h5 on button click the current date, next day date and previous day date.</p>
  
  <p>So if today is 10 April the next day should be 11 the next 12 while the previous have to work in the inverse mode.</p>
  
  <p>The problem is that in my code the days are set two by two or better if today is 10 April the next day will be 12 and next 14 but i can't get where is the problem.</p>
  
  <p>Here is the javascript part</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function setData(data) {
    if (data == "today") {
      $("#day").attr('data-giorno', new Date());
    }
    
    if (data == "prev") {
      var ieri = new Date($("#day").attr('data-giorno'));
      ieri.setDate(ieri.getDate() - 1);
      $("#day").attr('data-giorno', ieri);
    }
    
    if (data == "next") {
      var domani = new Date($("#day").attr('data-giorno'));
      domani.setDate(domani.getDate() + 1);
      $("#day").attr('data-giorno', domani);
    }
  }
  
  $('.btn-group input[type="button"][data-calendar-nav]').each(function() {
    var $this = $(this);
    $this.click(function() {
      setData($this.data('calendar-nav'));
    });
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div class="row  text-center"&gt;
    &lt;div class="col"&gt;
      &lt;div class="pull-left"&gt;
        &lt;h3 id="day" data-giorno="Wed Apr 10 2019 16:53:47 GMT+0200 (Ora legale dell’Europa centrale)"&gt;10 aprile 2019&lt;/h3&gt;
      &lt;/div&gt;
    &lt;/div&gt;
    &lt;div class="col"&gt;
      &lt;div class="btn-group pull-right"&gt;
        &lt;input type="button" class="btn btn-primary btn-sm" data-calendar-nav="prev" value="&lt;&lt;" /&gt;
        &lt;input type="button" class="btn btn-light btn-sm" data-calendar-nav="today" value="Oggi" /&gt;
        &lt;input type="button" class="btn btn-primary btn-sm" data-calendar-nav="next" value="&gt;&gt;" /&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>