compare two date using javascript

前端 未结 7 1523
轻奢々
轻奢々 2020-12-10 18:26

I have two date in which one is dd-mm-yyyy hh:mm format and another in dd-mm-yyyy (D1) format fristly i split the dd-mm-yyyy hh:mm fo

相关标签:
7条回答
  • 2020-12-10 18:57
    dateFirst = D1.split('-');
    dateSecond = D2.split('-');
    var value = new Date(dateFirst[2], dateFirst[1], dateFirst[0]); //Year, Month, Date
    var current = new Date(dateSecond[2], dateSecond[1], dateSecond[0]);
    

    than use the if condition

    if(D2<=D1)
    {
    console.log('ok');
    }
    else
    {
    console.log('something is wrong');
    }
    
    0 讨论(0)
提交回复
热议问题