Calculate year, month and day using javascript? : <p>I need to calculate the exact difference between two dates in days, months and years.</p>

<p>I have this function:</p>

<pre><code>const getAge = (dateString) =&gt; {
    const today = new Date();
    const birthDate = new Date(dateString);
    let age = today.getFullYear() - birthDate.getFullYear();
    const m = today.getMonth() - birthDate.getMonth();
    if (m &lt; 0 || (m === 0 &amp;&amp; today.getDate() &lt; birthDate.getDate())) {
        age -= 1;
    }
    return age;
};
</code></pre>

<p>It receives a date in YYYY-MM-DD format. At this time it outputs a exact number of years (6 years, or 5 if it's before "birthday").</p>

<p>I need it to output 5 years, 11 months and 29 days (as an example).</p>

<p>How can I achieve that?</p>
