title: Get days from substract to dates using Moment.js
body: <p>I want to set a countdown for events, so only on the case the event hasn't started, a countdown of the days before the event shows. The dates are stored on the database like this DD-MM-YYYY, so I convert them using Moment.js, but I still don't get the remaining days. Here is my code</p>
  
  <pre><code>moment.locale('es');
          var hoy = moment().format("DD-MM-YYYY");
          var finicio = moment("20-01-2015", "DD-MM-YYYY").format("DD-MM-YYYY");
          var ffin = moment("19-01-2015", "DD-MM-YYYY").format("DD-MM-YYYY");
          $(function () {
              if (finicio &lt; hoy) {
                  $("#estadoevento").text("EXPIRADO");
              }
              else if (finicio &gt; hoy) {
                  $("#estadoevento").text("EN ESPERA");
                  var contador = moment(finicio).diff(moment(hoy));
                  var espera = moment.duration(contador);
                  var restante = espera.asDays();
                  $("#contador").text("FALTAN " + restante + " DÍAS");
              }
              else {
                  $("#estadoevento").text("EN ESTE MOMENTO");
              }
          });
  </code></pre>
  
  <p>But I don't get the values, I don't know if I have to redeclare my variables, currently the code just shows a message on a span tag if event is expired, incoming or today, and works correctly.</p>
  
  <p>Variable finicio is the one that contains the starting date for the event, so if the event starts on five days, I wan't to get that number, I tried, but it returns a 0 value. I'm using jQuery too.</p>
  
  <p>contador variable is the substract of the two dates, variable espera gets the duration of contador, and finally restante changes into days, but I don't know where my code is wrong.</p>