JS determines that the end time cannot be less than the start time

1. Directly upload the code
Insert image description here

2. js code

				//获取到开始时间
                var begin = $("#begin").val();
                //获取到结束时间
                var end = $("#end").val();
                var arr1 = begin.split("-");
                var arr2 = end.split("-");
                var date1=new Date(parseInt(arr1[0]),parseInt(arr1[1])-1,parseInt(arr1[2]),0,0,0);
                var date2=new Date(parseInt(arr2[0]),parseInt(arr2[1])-1,parseInt(arr2[2]),0,0,0);
                if(date1.getTime()>date2.getTime()) {
    
    
                    alert('结束日期不能小于开始日期',this);
                    return false;
                }

Guess you like

Origin blog.csdn.net/weixin_45500785/article/details/107766864