计算时间差值 var date1=new Date('2022-01-21') var date2=new Date('2022-01-20') var days=parseInt((date1-date2)/1000*24*24*60) console.log('相差'+days+天)