📌  相关文章
📜  在javascript代码示例中检查两个日期之间的差异是否超过1个月

📅  最后修改于: 2022-03-11 15:03:43.290000             🧑  作者: Mango

代码示例2
const diffInMonths = (end, start) => {
   var timeDiff = Math.abs(end.getTime() - start.getTime());
   return Math.round(timeDiff / (2e3 * 3600 * 365.25));
}

const result = diffInMonths(new Date(2015, 3, 28), new Date(2015, 1, 25));

// shows month difference as integer/number
console.log(result);