function fun_showMx() { subwindowMx.show(true,true); } //转换查询条件中的string类型时间为data function stringToDate() { if(kssj!= null && kssj !="") { kssj = kssj.replace(/-/g,"/"); kssj = new Date(kssj); } if(jssj!= null && jssj !="") { jssj = jssj.replace(/-/g,"/"); jssj = new Date(jssj); } } // getDate var kssj; var jssj; //获取推送时间段 function getDate(type){ var today = new Date(); var years = today.getYear(); var months = today.getMonth()+1; var days = today.getDate(); var DAY = 1000*60*60*24; type = "lastWeek"; if(type =="lastDay") { //前一工作日 if(today.getDay()=="1") { kssj = new Date(getBeforNday(new Date(),today.getDay()+2)); jssj = new Date(getBeforNday(new Date(),today.getDay()+1)); } else if (today.getDay()=="7"){ kssj = new Date(getBeforNday(new Date(),2)); jssj = new Date(getBeforNday(new Date(),1)); } else { kssj = new Date(getBeforNday(new Date(),1)); jssj = new Date(); } // alert(kssj+"- -"+jssj); } if(type == "lastWeek") { //上一周 kssj = new Date(getBeforNday(new Date(),today.getDay()+6)); jssj = new Date(getBeforNday(new Date(),today.getDay()+1)); // alert(kssj+"- -"+jssj); } if(type == "lastMonth") { //上一月 var thisMonthFirstDay = getThisMonthFirstDay(new Date());//本月第一天 kssj = new Date(getLastMonthFirstDay(new Date())); jssj = new Date(getThisMonthFirstDay(new Date())); //alert(kssj+"- - -"+jssj); } str ="数据时间:"+ kssj.format('yyyy-MM-dd')+" 至 "+jssj.format('yyyy-MM-dd') ; flushDataCX(); debugger; document.getElementById("dataTime").value=str; } //---------------------------------------------------------------------- //前N天 function getBeforNday(date,n){ var yesterday_milliseconds=date.getTime()-n*1000*60*60*24; var yesterday = new Date(); yesterday.setTime(yesterday_milliseconds); var strYear = yesterday.getFullYear(); var strDay = yesterday.getDate(); var strMonth = yesterday.getMonth()+1; if(strMonth<10) { strMonth="0"+strMonth; } datastr = strYear+"/"+strMonth+"/"+strDay; return datastr; } function getYestoday(date){ var yesterday_milliseconds=date.getTime()-1000*60*60*24; var yesterday = new Date(); yesterday.setTime(yesterday_milliseconds); var strYear = yesterday.getFullYear(); var strDay = yesterday.getDate(); var strMonth = yesterday.getMonth()+1; if(strMonth<10) { strMonth="0"+strMonth; } datastr = strYear+"/"+strMonth+"/"+strDay; return datastr; } //获得上个月在昨天这一天的日期 function getLastMonthYestdy(date){ var daysInMonth = new Array([0],[31],[28],[31],[30],[31],[30],[31],[31],[30],[31],[30],[31]); var strYear = date.getFullYear(); var strDay = date.getDate(); var strMonth = date.getMonth()+1; if(strYear%4 == 0 && strYear%100 != 0){ daysInMonth[2] = 29; } if(strMonth - 1 == 0) { strYear -= 1; strMonth = 12; } else { strMonth -= 1; } strDay = daysInMonth[strMonth] >= strDay ? strDay : daysInMonth[strMonth]; if(strMonth<10) { strMonth="0"+strMonth; } if(strDay<10) { strDay="0"+strDay; } datastr = strYear+"/"+strMonth+"/"+strDay; return datastr; } //获得上一年在昨天这一天的日期 function getLastYearYestdy(date){ var strYear = date.getFullYear() - 1; var strDay = date.getDate(); var strMonth = date.getMonth()+1; if(strMonth<10) { strMonth="0"+strMonth; } if(strDay<10) { strDay="0"+strDay; } datastr = strYear+"-"+strMonth+"-"+strDay; return datastr; } function getThisMonthFirstDay(date){ var daysInMonth = new Array([0],[31],[28],[31],[30],[31],[30],[31],[31],[30],[31],[30],[31]); var strYear = date.getFullYear(); var strDay = date.getDate(); var strMonth = date.getMonth()+1; datastr = strYear+"/"+strMonth+"/"+"01"; return datastr; } //获得上个月在昨天这一天的日期 function getLastMonthFirstDay(date){ var daysInMonth = new Array([0],[31],[28],[31],[30],[31],[30],[31],[31],[30],[31],[30],[31]); var strYear = date.getFullYear(); var strDay = date.getDate(); var strMonth = date.getMonth()+1; if(strYear%4 == 0 && strYear%100 != 0){ daysInMonth[2] = 29; } if(strMonth - 1 == 0) { strYear -= 1; strMonth = 12; } else { strMonth -= 1; } strDay = daysInMonth[strMonth] >= strDay ? strDay : daysInMonth[strMonth]; if(strMonth<10) { strMonth="0"+strMonth; } if(strDay<10) { strDay="0"+strDay; } datastr = strYear+"/"+strMonth+"/"+"01"; return datastr; } //data类型转string Date.prototype.format = function(format) { var o = { "M+" : this.getMonth()+1, //month "d+" : this.getDate(), //day "h+" : this.getHours(), //hour "m+" : this.getMinutes(), //minute "s+" : this.getSeconds(), //second "q+" : Math.floor((this.getMonth()+3)/3), //quarter "S" : this.getMilliseconds() //millisecond } if(/(y+)/.test(format)) format=format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length)); for(var k in o)if(new RegExp("("+ k +")").test(format)) format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length)); return format; }