var CountTime = 2 * 60 * 1000; var Countdown = CountTime; function RefreshTime() { var dataObj = new Date(); dataObj.setTime(Countdown); $("#jsCountTime").html(dataObj.getMinutes() + "分钟" + dataObj.getSeconds() + "秒"); Countdown = Countdown - 1000; if (Countdown <= 0) { if ($("#jsLastStatus").val() != GetDateString()) { MonitorAjax(); } Countdown = CountTime; $("#jsLastStatus").val(GetDateString()); } window.setTimeout(function () { RefreshTime(); }, 1000); } function GetDateString() { var dateTime = new Date(); var year = dateTime.getYear(); //获取当前年份(2位) var moonth = dateTime.getMonth(); //获取当前月份(0-11,0代表1月) var day = dateTime.getDay(); //获取当前星期X(0-6,0代表星期天) var hour = dateTime.getHours(); return year + "" + moonth + "" + day + "" + hour; } function NowTime() { var nowDate = new Date(); var week; if (new Date().getDay() == 0) week = "星期日" if (new Date().getDay() == 1) week = "星期一" if (new Date().getDay() == 2) week = "星期二" if (new Date().getDay() == 3) week = "星期三" if (new Date().getDay() == 4) week = "星期四" if (new Date().getDay() == 5) week = "星期五" if (new Date().getDay() == 6) week = "星期六" var Nowtime = nowDate.getFullYear() + "-" + (nowDate.getMonth()+1) + "-" + nowDate.getDate() + " " + week; $("#jsnowtime").html(Nowtime); } function numToArr(num) { var result = []; var num1 = num; while (num1 / 10 >= 1) { result.push(num1 % 10); num1 = parseInt(num1 / 10); } result.push(num1 % 10); for (var i = result.length; i < 4; i++) { result.push(0); } return result; }