The resource loading... loading...

We have written a test code for users to learn how to use it, throwing quotes and quotes.

Author: Inventors quantify - small dreams, Created: 2016-05-13 14:41:39, Updated: 2019-08-01 10:32:30

Recently, inventors have quantified The official group has a group of friends who ask questions, such as timely WeChat push, to facilitate the group's learning, especially written a section of test code.

The policy refers to this template (very small pediatrics, reference learning,), which is used to convert milliseconds of time into time that can be seen clearly.img

function main(){
    var initTime = (new Date()).getTime() ; //在程序开始运行的时候 ,先获取一个初始时间。
    Log("程序起始时间:",$.getTimeByNormal(initTime) ); //输出  初始时间
    var preDif = 0; //整周期计数,这里周期设置为   30分钟吧
    var str = "";  //信息字符串
    while(true){ // 一个不停的循环
        var nowTime = (new Date()).getTime(); //程序运行中 每次循环获取 当时的时间
        if(  Math.floor((nowTime - initTime) / (1000*60*30) ) !== preDif ){ //计算  程序 开始执行时  到现在 的时间差(单位毫秒) 并除以 一个周期,计算出已经过去了几个完整周期(不满一个周期的已经用Math.floor函数舍去,不明白的百度)
        //并对比 记录前一个的整周期, 整周期不相等即 发生变化,即已经过去了一个整周期 30*60*1000毫秒
        //1000*60*30   这个的意思就是   (1000毫秒 = 1秒)   ,  30分钟  是 30 个 60 秒,也就是 30 个  60 * 1000 毫秒, 也就是30*60*1000毫秒
            str = $.getTimeByNormal(nowTime);//把 此刻的 毫秒时间  转换成  字符串(能看懂的)
            Log("从程序开始执行,已过30分钟!提醒。"+"--现在时间:"+str+"推送微信@" ); //输出一条信息  并推送微信
            preDif = Math.floor((nowTime - initTime) / (1000*60*30) ) ; //用于对比的 整周期已经发生变化,更新
        }
        Sleep(2000); //暂停一会, 轮询
    }
}

Less familiar students can copy past trials. Users without groups can add official QQ groups: 309368835


More