zoukankan      html  css  js  c++  java
  • js倒计时

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>js倒计时</title>
    <style>
        .div {
            height:500px;
            width:300px;
            margin:20% auto;}
        h3,h2 { text-align:center;}
    </style>
    </head>
    
    <body bgcolor="#FF0000">
    <div class="div">
    <h3>距元旦还有</h3>
    <h2 id="time"></h2>
    </div>
    <script>
    function tt(){
        var end = "2018-01-01 00:00:00"
        var endDate = new Date(end).getTime();
        //alert(endDate);
        var star = new Date();
        var starDate = star.getTime();
        var temp = endDate-starDate;
        var day = Math.floor(temp/(1000*60*60*24));
        var hh = Math.floor((temp-day*24*60*60*1000)/(1000*60*60));
        var mm = Math.floor((temp-day*24*60*60*1000-hh*3600000)/(1000*60)); 
        var ss = Math.floor((temp-day*24*60*60*1000-hh*3600000-mm*60000)/1000);
        //alert(day+"--"+hh+"--"+mm+"--"+ss);
        document.getElementById("time").innerHTML = day+""+hh+"小时"+mm+"分钟"+ss+"";
        }
        tt();
        window.setInterval(tt,1000);
    </script>
    </body>
    </html>

  • 相关阅读:
    SQL注入常见处理方式
    git操作常用
    crontab 基本参数
    替代PHP格式化成无符号数后精度不对问题
    替代PHP两个大数相乘会有精度损失
    排序算法
    迁移服务器资源到新服务器
    数据库分库分表思路
    drupal 常用表单元素
    drupal模块开发
  • 原文地址:https://www.cnblogs.com/liu-heng/p/6805314.html
Copyright © 2011-2022 走看看