倒计时原理

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+'秒' );

你可能感兴趣的:(倒计时原理)