• 时间倒计时 JS


    <div id="keleyi">Christmas Countdown</div>
    
    <script type="text/javascript">
    function iCounter() {
        var myDate = (new Date().getMonth()>=11 && new Date().getDate()>29)?(new Date().getFullYear())+1:(new Date().getFullYear());//如果当前月份大于11月并且天数大于29就让当前年份+1否则当前年份不变;
        var date = new Date();
        var tDate = new Date("April 28, "+myDate+" 0:0:00");
        var timeDifference = (tDate - date)/1000;//时间差
        var oneMin = 60; //天 时 分 都换算成秒
        var oneHour = 60*60;
        var oneDay = 60*60*24;
        var totalDay = Math.floor(timeDifference/oneDay);
        var totalHour = Math.floor((timeDifference-totalDay*oneDay)/oneHour);
        var totalMin = Math.floor((timeDifference - totalDay*oneDay -totalHour*oneHour)/oneMin);
        var totalSec = Math.floor((timeDifference - totalDay*oneDay - totalHour*oneHour - totalMin*oneMin));
        if(totalDay == 0){ totalDay = ''}else{totalDay};
        document.getElementById('kel' + 'eyi').innerHTML = '28日<br/>' + totalDay  + totalHour + '<span>时,</span>' + totalMin + '<span>分,</span>' + totalSec + '<span>秒。</span>';
        setTimeout(iCounter,1000);
    }
    iCounter();
    
    </script>
  • 相关阅读:
    ubuntu16.04自动删除内核
    禅道服务数据的迁移
    k8s常用命令3
    使用logstash迁移es集群数据
    es集群迁移脚本
    helm常用命令1
    【操作】python2升级到python3
    【推荐】构建脚本之shell编写规范
    【推荐】linux使用zip命令
    Sublime使用大全
  • 原文地址:https://www.cnblogs.com/fanxiaowu/p/4460233.html
Copyright © 2020-2023  润新知