title: jquery countdown years months days
body: <p>I have this countdown in jQuery, but the months and days are not shown the correct number. The error is in the calculation of the months and days:</p>
  
  <pre><code>seconds / (60 * 60 * 24 * 30.41666666 * 12)
  </code></pre>
  
  <p>This is the Jquery:</p>
  
  <pre><code>(function($)  {
  
  $.fn.countdown = function(options, callback) {
  
  var settings = { 'date': null }
  
  if (options) {
    $.extend(settings, options)
  }
  
  this_sel = $(this);
  
  function count_ecec() {
    eventDate = Date.parse(settings['date']) / 1000;
    currentDate = Math.floor( $.now() / 1000 );
  
    if (eventDate &lt;= currentDate ) {
      callback.call(this);
      clearInterval(interval);
    }
  
    seconds = eventDate - currentDate;
  
    if (this_sel.find('.years').length &gt; 0) {
      years = Math.floor( seconds / ( 60 * 60 * 24 * 30.41666666 * 12 ) );
      seconds -= years * 60 * 60 * 24 * 30.41666666 * 12  ;
    }
  
    if (this_sel.find('.days').length &gt; 0) {
      days = Math.floor( seconds / ( 60 * 60 * 24 * 30.41666666 ) );
      seconds -= days * 60 * 60 * 24 * 30.41666666;
  }
      if (this_sel.find('.month').length &gt; 0) {
      month = Math.floor( seconds / ( 60 * 60 * 24 ) );
      seconds -= month * 60 * 60 * 24 ;
  }
    if (!isNaN(eventDate)) {
      if (this_sel.find('.years').length &gt; 0) {
        this_sel.find('.years').text(years);
    }
    if (this_sel.find('.days').length &gt; 0) {
      this_sel.find('.days').text(days);
    }
    if (this_sel.find('.month').length &gt; 0) {
      this_sel.find('.month').text(month);
    }
    }
  }
  count_ecec();
  interval = setInterval(count_ecec, 1000);
  }
  
  }) (jQuery);
  </code></pre>
  
  <p>And this is the HTML:</p>
  
  <pre><code> &lt;div class="large-5 large-centered columns counter"&gt;                       
               &lt;div class="container"&gt;
                &lt;div id="countdown"&gt;
                  &lt;div class="large-4 columns"&gt;   
                      &lt;span&gt;Día&lt;/span&gt;
                      &lt;span class="days"&gt;&lt;/span&gt; 
                  &lt;/div&gt;
                  &lt;div class="large-4 columns"&gt;
                      &lt;span&gt;Mes&lt;/span&gt;
                      &lt;span class="month"&gt;&lt;/span&gt; 
                  &lt;/div&gt;
                  &lt;div class="large-4 columns"&gt;
                      &lt;span&gt;Año&lt;/span&gt;
                      &lt;span class="years"&gt;&lt;/span&gt; 
                  &lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
            &lt;/div&gt;
  
  &lt;script src="js/countdown.js" charset="utf-8"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  $(document).ready(function() {
    $('#countdown').countdown({date: '15/12/2016'}, function() {
      $('#countdown').text('');
    });
  });
  &lt;/script&gt;
  </code></pre>