How to check 2 date fields and compare to see which date is ahead, behind or the same

前端 未结 3 951
清酒与你
清酒与你 2021-01-26 11:00

I\'m working with 2 dates that are posted back to me in a textbox as strings in this format 03/02/2010. One is the current completion date and the second is the final completion

3条回答
  •  野性不改
    2021-01-26 11:38

    Convert it to US format

    function dateUS(date)
    {
        var date = date.split("/");
        return date[2] + '/' + date[1] + '/' + date[0];
    }
    

    and then

    if(dateUS(dateCurrent) < dateUS(dateFinal))
    {
      //your code
    }
    

提交回复
热议问题