title: How to Convert Seconds into Year, Month, Days, Hours, Minutes respectively?
body: <p>I implemented this logic where I am getting difference between 2 dates and times from <strong>Moment.js</strong> as seconds, and I need to convert these seconds into <code>1 Year 3 Months 10 Days 5 Hours 45 Minutes</code> format.</p>
  
  <pre><code>var numyears = Math.floor(seconds / 31536000);
  var nummonths = Math.floor((seconds % 31536000) / 2628000);
  var numdays = Math.floor(((seconds % 31536000) % 2628000) / 86400);
  var numhours = Math.floor((((seconds % 31536000) % 2628000) % 86400)/3600);
  var numminutes = Math.floor((((seconds % 31536000) % 86400) % 3600) / 60);
  </code></pre>
  
  <p>I am getting the correct values up to days, but it's having problem from hours onwards.</p>