js比较日期大小


//获取当前时间
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('第二个大');
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM