预览
本站已运行了
天
使用方法
在主题页尾信息附加代码
或footer.php
文件适当位置添加下列代码
<div style="color: #39C5BB;">本站已运行了 <span id="daysRunning"></span> 天</div>
<script type="text/javascript">
const startDate = new Date("2024-07-01"); // 设置起始日期
const currentDate = new Date();
const timeDifference = currentDate - startDate;
const days = Math.floor(timeDifference / (1000 * 60 * 60 * 24));
document.getElementById("daysRunning").textContent = days;
</script>
如主题中页尾信息
和附加代码
分开
则页尾信息
和附加代码
分别添加代码的两部分
<div style="color: #39C5BB;">本站已运行了 <span id="daysRunning"></span> 天</div>
<script type="text/javascript">
// 设置起始日期
const startDate = new Date("2024-07-01"); // 设置起始日期
// 获取当前日期
const currentDate = new Date();
// 计算日期差异,转换为天数
const timeDifference = currentDate - startDate;
const days = Math.floor(timeDifference / (1000 * 60 * 60 * 24));
// 更新网页中的天数显示
document.getElementById("daysRunning").textContent = days;
</script>
自定义样式
在div标签内使用CSS更改,可自行查看CSS相关知识
Comments NOTHING