博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
倒计时
阅读量:6959 次
发布时间:2019-06-27

本文共 1258 字,大约阅读时间需要 4 分钟。

js代码

var EndTime= new Date('2017/2/18 00:00:00'); //设置到期时间    var NowTime = new Date();  //当前时间    var t =EndTime.getTime() - NowTime.getTime();  //时间差    var d=Math.floor(t/1000/60/60/24); //剩余天数    var h=Math.floor(t/1000/60/60%24);  //剩余小时数    var m=Math.floor(t/1000/60%60);  //剩余分钟天数    var s=Math.floor(t/1000%60); //剩余秒数    var getCodeTimer = setInterval(function() {        t--;        $('#t-d').html(d+'天');        $('#t-h').html(h+'小时');        $('#t-m').html(m+'分');        if (t <= 0) {     //当时间差小于等于0时,归零            clearInterval(getCodeTimer);            $('#t-d').html(0+'天');            $('#t-h').html(0+'小时');            $('#t-m').html(0+'分');        }    }, 100);

 

第二种方式:

// 倒计时    function GetRTime(){       var EndTime= new Date('2017/3/19 00:00:00');       var NowTime = new Date();       var t =EndTime.getTime() - NowTime.getTime();       var d=Math.floor(t/1000/60/60/24);       var h=Math.floor(t/1000/60/60%24);       var m=Math.floor(t/1000/60%60);       var s=Math.floor(t/1000%60);       $(".day").html(d);       $(".hour").html(h);       $(".minute").html(m);       $(".second").html(s);       if (t<=0) {        clearInterval(GetRTime);       }   }   setInterval(GetRTime,0);

 

转载于:https://www.cnblogs.com/qiye2016/p/6405660.html

你可能感兴趣的文章
jackson用法
查看>>
一步一步搭建springboot+mybatis+jta框架
查看>>
C++文件操作和模板
查看>>
八行代码解决八皇后问题(c++)
查看>>
初级模拟电路:1-8 齐纳二极管
查看>>
基线系统需要受到更多关注:基于词向量的简单模型
查看>>
自然语言处理中的自注意力机制(Self-attention Mechanism)
查看>>
PIVOT 用于将列值旋转为列名
查看>>
php 内存超出
查看>>
listtoordereddict 多列表转化为字典
查看>>
----uni-app之APP关联小程序实现扫描APP二维码跳转关联小程序----
查看>>
socket网络编程-字典
查看>>
slice,substr和substring方法的区别
查看>>
javaweb中的标签的核心标签库的常用标签
查看>>
copy与mutableCopy
查看>>
Python2和Python3
查看>>
C#中结构函数和析构函数的用法
查看>>
CC2540串口输出调试功能
查看>>
px,dp,sp三者的转换
查看>>
forward_list详解
查看>>