NexT侧边栏添加网站运行时间


版本

文件路径

1
/blog/node_modules/hexo-theme-next/layout/_partials/sidebar/site-overview.njk

插入代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<div class="site-state-wrap animated">
<span id="timeDate">Loading...</span>
<script>
var now = new Date();
function createtime()
{
var grt= new Date("01/02/2021");//此处修改为你的建站时间或者网站上线时间
now.setTime(now.getTime()+250);
days = (now - grt ) / 1000 / 60 / 60 / 24; dnum = Math.floor(days);
document.getElementById("timeDate").innerHTML = "Running for "+dnum+" days.";
}
setInterval("createtime()",250);
</script>
</div>

效果展示

见本网站home页侧边栏