倒计时
<p id="timeTxt"></p>
<script type="text/javascript">
function add(m){
return m<10 ? "0"+m : m;
}
var time2 = new Date().getTime();
function getTime(time){
var nowTime = new Date("2018-12-15 12:30:00").getTime();
var TimeCon = (nowTime - time)/1000;
TimeCon = parseInt(TimeCon);
var d = parseInt(TimeCon/(60*60*24));
var h = parseInt(TimeCon/(60*60)%24);
var m = parseInt(TimeCon/60%60);
var s = parseInt(TimeCon%60);
return d+"天"+add(h)+"小时"+add(m)+"分钟"+add(s)+"秒";
}
setInterval(function(){
var that = this;
time2 +=1000;
console.log(time2);
document.getElementById("timeTxt").innerHTML = that.getTime(time2);
console.log(that.getTime(time2));
},1000);
</script>
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步