How to check date with current date using jQuery

前端 未结 6 1275
长情又很酷
长情又很酷 2020-12-11 08:27

I want to check my date is greater than current date

$(\"#EndDate\").val() =\"5/13/2014\" ->M/d/y

Please find below code



        
6条回答
  •  时光说笑
    2020-12-11 08:53

    i found solution my self by modifying code like this

    if (Date.parse(new Date().setHours(0, 0, 0, 0)) > Date.parse($("#EndDate").val())) {
    //
    }
    

    to avoid time comparison. is there any other better way to do compare dates in efficient manner without any plugin.

提交回复
热议问题