WellTech - 小白记录3-网站运行时间倒计时代码

在网站的底部添加网站已运行的倒计时
通过下面的代码实现:

"<span id="defaultCountdown"></span>
<script language=javascript>
function show_date_time(){window.setTimeout("show_date_time()", 1000);BirthDay=new Date("10-24-2021 13:12:24");//建站日期
today=new Date();
timeold=(today.getTime()-BirthDay.getTime());
sectimeold=timeold/1000
secondsold=Math.floor(sectimeold);
msPerDay=24*60*60*1000
e_daysold=timeold/msPerDay
daysold=Math.floor(e_daysold);
e_hrsold=(daysold-e_daysold)*-24;
hrsold=Math.floor(e_hrsold);
e_minsold=(hrsold-e_hrsold)*-60;
minsold=Math.floor((hrsold-e_hrsold)*-60);
seconds=Math.floor((minsold-e_minsold)*-60);
defaultCountdown.innerHTML="已傲游 "+daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒" ;}
show_date_time();
</script>
<style>
#defaultCountdown{color:#545454;font-size:13px;}
</style>"


效果如主页底栏

tagged by none  

Post a new comment

© Powered by Typecho 京ICP备16019447号