直接上代码
function check(dt1,dt2){
dt1 = new Date(dt1.replace(/-/g,"/"));
dt2 = new Date(dt2.replace(/-/g,"/"));
if(dt1.getFullYear()==dt2.getFullYear() && dt1.getMonth()==dt2.getMonth()) alert("同月");
else alert("不同月");
}
check("2020-12-20","2020-12-1")