zoukankan      html  css  js  c++  java
  • 比较low的js代码

    获取当前时间

    let nowTime ="00:00:00"
    let getNowTime = ()=> {
    	const now = new Date();
    	const hour = now.getHours() < 10 ? '0' + now.getHours() : now.getHours();
    	const min = now.getMinutes() < 10 ? '0' + now.getMinutes() : now.getMinutes();
    	const sec = now.getSeconds() < 10 ? '0' + now.getSeconds() : now.getSeconds();
    	nowTime = `${hour}:${min}:${sec}`;
    	setTimeout(getNowTime,1000)
    }
    
    
    
    getNowTime() // 获取当前时间
    

      

    // 写的太low了,再看我都佩服自己了,写的啥玩意

    //倒计时

    var timer=null;
    var interval = 1000; 
    function ShowCountDown(year,month,day,hour,minute,second,divname) { 
    var cc = document.getElementById(divname); 
    var now = new Date(); 
    var endDate = new Date(year,month-1,day,hour,minute,second); 
    var leftsecond = Math.round((endDate-now)/1000);
    if(leftsecond<0){
        clearInterval(timer);
        return;
    }else{
        //var day1=parseInt(leftsecond/(24*60*60)); 
        var ofd=parseInt(leftsecond/3600/24);//计算天数
        var ofh=parseInt((leftsecond%(3600*24))/3600);//计算小时
        var ofm=parseInt((leftsecond%3600)/60);//计算分
        var ofs=leftsecond%60;//计算秒
        if (ofd <= 9) ofd = "0" + ofd;
        if (ofh <= 9) ofh = "0" + ofh;
        if (ofm <= 9) ofm = "0" + ofm;
        if (ofs <= 9) ofs = "0" + ofs; 
            cc.innerHTML = ofd+"天"+ofh+"小时"+ofm+"分"+ofs+"秒";
        }
    } 
        timer=setInterval(function()        {ShowCountDown(2017,7,10,16,27,10,'divdown1');}, interval);//传入年月日时分秒,通过ID得到存放倒计时的元素    
    

      

  • 相关阅读:
    hdu 4534 郑厂长系列故事——新闻净化 夜
    poj 1185 炮兵阵地 夜
    hdu 2586 How far away ? 夜
    C. Shaass and Lights 夜
    hdu 4536 XCOM Enemy Unknown 夜
    根据BAPI_PO_CREATE1创建采购订单
    301、404、200、304、500HTTP状态
    js检查Page.IsValid
    查看linq的生成语句
    uploadfile和Image实现图片预览
  • 原文地址:https://www.cnblogs.com/zwp06/p/7363698.html
Copyright © 2011-2022 走看看