1、字符串转日期格式
var stringToDate = function(dateStr,separator){ if(!separator){ separator="-"; } var dateArr = dateStr.split(separator); var year = parseInt(dateArr[0]); var month; //处理月份为04这样的情况 if(dateArr[1].indexOf("0") == 0){ month = parseInt(dateArr[1].substring(1)); }else{ month = parseInt(dateArr[1]); } var day = parseInt(dateArr[2]); var date = new Date(year,month -1,day); return date; }
日期比较
var dateFeedBack = stringToDate(gfeedbackDataStore.getRowSet().getRow(0).getItemValue("svfd_FEEBBACK_DATE")); var dateNow = stringToDate(callback_date); var days1 = parseInt(dateFeedBack.getTime()/(1000*60*60*24)); var days2 = parseInt(dateNow.getTime()/(1000*60*60*24)); if((days2-days1)>7){ alert("提示:总部确认日期7天内才可退单!"); return; }
时间: 2024-10-27 06:07:05