管理员

代码说明:

代码执行的最终结果date3为当前时间点到第二天早上6:05的毫秒数.

Date.prototype.Format = function (fmt) {
    var o = {
        "M+": this.getMonth() + 1, //月份
        "d+": this.getDate() + 1, //日
        "h+": this.getHours(), //小时
        "m+": this.getMinutes(), //分
        "s+": this.getSeconds(), //秒
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
};
var time_range = function (beginTime, endTime, nowTime) {
var strb = beginTime.split (":");
if (strb.length != 2) {return false;}
var stre = endTime.split (":");
if (stre.length != 2) {return false;}
var strn = nowTime.split (":");
if (stre.length != 2) {return false;}
var b = new Date ();
var e = new Date ();
var n = new Date ();
b.setHours (strb[0]);
b.setMinutes (strb[1]);
e.setHours (stre[0]);
e.setMinutes (stre[1]);
n.setHours (strn[0]);
n.setMinutes (strn[1]);
if (n.getTime () - b.getTime () > 0 && n.getTime () - e.getTime () < 0) {return true;} else {return false;}
};
var NextStartTime = new Date().Format("yyyy/MM/dd 06:05:00");
var NextStartDate = new Date().Format("yyyy/MM/dd");
// log(NextStartDate);
var NowTime = new Date(new Date().getTime() - 24*60*60*1000).Format("hh:mm");
// log(NowTime);
if (time_range ("00:00", "06:00", NowTime) == true) {
    NextStartTime = new Date(new Date().getTime() - 24*60*60*1000).Format("yyyy/MM/dd 06:05:00");
}
var date1= NextStartTime;  //开始时间
var date2 = new Date().getTime();    //结束时间
var date3 = new Date(date1).getTime() - date2;   //时间差的毫秒数
log('下次执行时间: ' + NextStartTime);
sleep(date3);