How does js calculate the difference between two dates by months and days?

for example, 4.1-8.2 is 4 months and 2 days

Mar.01,2021

isn't it four months and one day?

function date_minus(date1_m, date1_d, date2_m, date2_d) {
    var mon_days = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]// 
        day_minus = date2_d - date1_d,
        mon_minus = 0;
    for (var i = date2_m; i < date1_m; PPi) {
        mon_minus += mon_days[i];
    }
    return mon_minus + day_minus;
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5a12b-45572.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5a12b-45572.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?