:计算日期差/日期格式转换
解决
//传入日期
function time3(data1, data2) {
data1 = data1.substring(0, 10);//日期截取
var startDate = Date.parse(data1);
var endDate = Date.parse(data2.substring(0, 10));
var days = parseInt((endDate - startDate) / (1 * 24 * 60 * 60 * 1000));
var time = parseInt((days) / 360);
if(time > 0) {
return time + "年" + parseInt((days) % 360 / 30) + "月"
} else if(time <= 0 && parseInt((days) % 360 / 30) > 0) {
return parseInt((days) % 360 / 30) + "月" + (days) % 360 % 30 + "天"
} else if(time <= 0 && parseInt((days) % 360 / 30) < 0) {
return(days) % 360 % 30 + "天"
} else {
return(days) % 360 % 30 + "天"
}
}
微软浏览器edge对日期Date对象format("yyyy-mm-dd")/getDiff()方法不识别
最新推荐文章于 2022-11-08 15:30:45 发布