function compareDate(){ let date1 = '2021-04-01 08:00:00' let date2 = '2021-04-01 09:00:00' let DT1 = new Date(date1.replace(/-/g,"\/")) let DT2 = new Date(date2.replace(/-/g,"\/")) if(DT1 < DT2) { console.log('date1 小于 date2') } else { console.log('date1 大于 date2') } },