function dateSubMonth(date) {
var date1 = new Date(date);
var date2 = new Date();
var monthCount = parseInt(date2.getFullYear() - date1.getFullYear()) * 12 - date1.getMonth() + date2.getMonth();
var resM = monthCount % 12;
var resY = parseInt(monthCount / 12);
var resStr = "";
if (resY != 0) {
resStr += resY + "年"
}
if (resM != 0) {
resStr += resM + "月"
}
if (resStr == "") {
resStr = "0";
}
return resStr;
}
js 时间减 获得年月(计算工龄,年龄)
最新推荐文章于 2023-09-08 23:55:46 发布