Answers for "Difference in Months between two dates in JavaScript"

0

Difference in Months between two dates in JavaScript

function monthDiff(d1, d2) {
    var months;
    months = (d2.getFullYear() - d1.getFullYear()) * 12;
    months -= d1.getMonth();
    months += d2.getMonth();
    return months <= 0 ? 0 : months;
}
Posted by: Guest on April-08-2021

Code answers related to "Difference in Months between two dates in JavaScript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language