给网站底部添加运行时间

在合适的位置添加以下代码
例如本主题添加位置 usr/themes/cuteen/include/footer.php
</>html代码

<span id = "runtime_span"></span>
    <script type = "text/javascript">
    function show_runtime()
    {window.setTimeout("show_runtime()",1000);X=new 
    Date("1/01/2021 00:00:00"); //初始建站时间这里修改  月/日/年
    Y=new Date();T=(Y.getTime()-X.getTime());M=24*60*60*1000;
    a=T/M;A=Math.floor(a);b=(a-A)*24;B=Math.floor(b);c=(b-B)*60;C=Math.floor((b-B)*60);D=Math.floor((c-C)*60);
    runtime_span.innerHTML="网站已运行: "+A+"天"+B+"小时"+C+"分"+D+"秒"}show_runtime();
    </script>

</>php代码

<center>
今天是:<span><script language=Javascript type=text/Javascript> 
var day=""; 
var month=""; 
var ampm=""; 
var ampmhour=""; 
var myweekday=""; 
var year=""; 
mydate=new Date(); 
myweekday=mydate.getDay(); 
mymonth=mydate.getMonth()+1; 
myday= mydate.getDate(); 
myyear= mydate.getYear(); 
year=(myyear > 200) ? myyear : 1900 + myyear; 
if(myweekday == 0) 
weekday=" 星期日 "; 
else if(myweekday == 1) 
weekday=" 星期一 "; 
else if(myweekday == 2) 
weekday=" 星期二 "; 
else if(myweekday == 3) 
weekday=" 星期三 "; 
else if(myweekday == 4) 
weekday=" 星期四 "; 
else if(myweekday == 5) 
weekday=" 星期五 "; 
else if(myweekday == 6) 
weekday=" 星期六 "; 
document.write(year+"年"+mymonth+"月"+myday+"日 "+weekday); 
</script>
</div>
<center><b><FONT COLOR="#008B00">【本站已经可爱滴运行】</FONT></b> 
<span id="span_dt_dt"></span> 
<SCRIPT language=javascript> 
<!-- 
//document.write(""); 
function show_date_time(){ 
window.setTimeout("show_date_time()", 1000); 
BirthDay=new Date("3-9-2020 08:00:00");//建站日期 
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); 
span_dt_dt.innerHTML=daysold+"天"+hrsold+"小时"+minsold+"分"+seconds+"秒" ; 
} 
show_date_time(); 
//--> 
</SCRIPT>
</center>
</span>

演示图
CF413EC3-013D-4528-8AB6-2E48EEF1A807.png

原文转载: 学哥博客

评论区
头像