• js 倒计时效果


       var count= countTime('2016-12-31');
            var time=document.createElement('div');
            time.id='time';
            document.body.appendChild(time);
            var showTime=document.getElementById("time");

            showTime.innerHTML=count;

            setInterval(function(){
                 count= countTime('2016-12-31');
                 showTime.innerHTML=count;

            },1000);
               

            function countTime(endtime){
                    var endT= endtime.replace(/-/g,"/");//字符串转化为日期
                    var endTime= new Date(endT);
                    var nowTime= new Date();
                    var t=endTime.getTime()-nowTime.getTime();
                    var d=0;
                    var h=0;
                    var m=0;
                    var s=0;
                    if(t>=0){
                      d=Math.floor(t/1000/60/60/24);
                      h=Math.floor(t/1000/60/60%24);
                      m=Math.floor(t/1000/60%60);
                      s=Math.floor(t/1000%60);
                    }
                    h=h<10?"0"+h:h;
                    m=m<10?"0"+m:m;
                    s=s<10?"0"+s:s;
                    return d+":"+h+":"+m+":"+s;
            }

  • 相关阅读:
    解决ScrollView嵌到listView冲突问题
    Popupwindow 的简单实用,(显示在控件下方)
    BroadCast,BroadCastReceiver
    NSURLSession
    sirikit
    MJExtension使用
    iOS中的translucent和automaticallyAdjustsScrollViewInsets用法
    如何获取LanuchImage-1(详细)
    如何获取LanuchImage
    MJRefresh详解
  • 原文地址:https://www.cnblogs.com/sandy-happyhour/p/5337040.html
Copyright © 2020-2023  润新知