How can I compare date/time values using the jQueryUI datepicker and HTML5 time input?

和自甴很熟 提交于 2019-12-02 01:30:18

Here's an approach. You need to test to see if the dates are the same, and then inside that, append the times to new date objects that you can then compare. (There might be a faster way to do this, but this works in testing, here: http://jsfiddle.net/mori57/SEqVE/):

} else if(begD.toString() == endD.toString() ){
    var dteString = begD.getFullYear() + "/" + (begD.getMonth()+1) + "/" + begD.getDate();
    var begT = new Date(dteString + " " + $('#BeginTime').val());
    var endT = new Date(dteString + " " + $('#EndTime').val());

    if( begT > endT ){
        alert('Begin date must be before End date');
        $('#BeginTime').focus();
        return false;
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!