JS to determine the size of two time sample code
- 2020-03-30 01:33:28
- OfStack
As follows:
function validTime(startTime,endTime){
var arr1 = startTime.split("-");
var arr2 = endTime.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(' The end date must not be less than the start date ',this);
return false;
}else{
return true;
}
return false;
}