话不多说,直接上代码
<span id="runtime_span">网站已在风雨中运行:267天23小时45分40秒</span><script type="text/javascript">function show_runtime(){window.setTimeout("show_runtime()",1000);X=new Date("10/24/2019 10:52:50");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>
使用方法:将上述代码中的时间,修改为你博客或者网站的运行开始时间即可。
之后将修改过后的代码,放到你网站喜欢的位置就好啦。