js判断两日期相差的天数

it2022-05-09  34

function checkTime() { var sDate1 = $( " #inputOrderTimeStart " ).val(); var sDate2 = $( " #inputOrderTimeEnd " ).val(); var aDate, oDate1, oDate2, iDays aDate = sDate1.split( " - " ) oDate1 = new Date(aDate[ 1 ] + ' - ' + aDate[ 2 ] + ' - ' + aDate[ 0 ]) // 转换为12-18-2002格式 aDate = sDate2.split( " - " ) oDate2 = new Date(aDate[ 1 ] + ' - ' + aDate[ 2 ] + ' - ' + aDate[ 0 ]) iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 / 24 ) // 把相差的毫秒数转换为天数 if (iDays > 90 ) { alert( " 查询时间范围超过90天,请重新选择! " ); return false ; } } < input id = " inputOrderTimeStart " name = " inputOrderTimeStart " runat = " server " type = " text " class = " input80px " onfocus = " WdatePicker({isShowClear:true,readOnly:true}) " /> < input id = " inputOrderTimeEnd " name = " inputOrderTimeEnd " runat = " server " type = " text " class = " input80px " onfocus = " WdatePicker({isShowClear:true,readOnly:true}) " /> < asp:Button ID = " btnSearch " class = " button_2 mgLeft0 " runat = " server " Text = " 查询 " onclick = " btnSearch_Click " OnClientClick = " return checkTime(); " />

转载于:https://www.cnblogs.com/yy-sun/articles/1998748.html


最新回复(0)