美文网首页
倒计时原理

倒计时原理

作者: 舞城 | 来源:发表于2015-09-01 17:31 被阅读0次
    var iNow = new Date();
    var iNew = new Date(2015, 7, 15, 19, 50, 0);
    var iNew = new Date(July 15, 2015, 19, 50, 0);
    var t = Math.floor((iNew - iNow) / 1000); 毫秒
    **转成:**
    天:Math.floor(t/86400)
    时:Math.floor(t%86400/3600)
    分:Math.floor(t%86400%3600/60)
    秒:t%60
    alert( Math.floor(t/86400)+'天'+Math.floor(t%86400/3600)+'时'+Math.floor(t%86400%3600/60)+'分'+t%60+'秒' );
    

    相关文章

      网友评论

          本文标题:倒计时原理

          本文链接:https://www.haomeiwen.com/subject/baklcttx.html