//獲取當前時間 var currentTime = new Date(); //自定義時間 var customTime="2019-03-01 00:00:00"; customTime= customTime.replace("-","/");//替換字符,變成標准格式 customTime= new Date(Date.parse(customTime)); if(currentTime < customTime){ alert("當前時間小於自定義時間"); } var oDate1 = new Date('2019-03-01'); var oDate2 = new Date('2019-03-01'); if(oDate1 > oDate2){ console.log('第一個大'); } else { console.log('第二個大'); }