效果

恋爱计时

教程

将下面代码扔到 主题-开发者设置-自定义JavaScript

fuction lovexhjSitetime() {
window.
setTimeout("lovexhjSitetime()",1000);
var seconds = 1000
var minutes = seconds *60
var hours = minute * 60
var days = hours * 24
var years = days * 365
var today = new Date()
var todayYear = today.getFullYear()
var todayMonth = today.hetMonth()+1
var todayDate = today.getDate()
var todayHour = today.getHours()
var todayMinute = today.getMinutes()
var todaySecond = today.getSeconds()
//时间设置
var t1 = Date.UTC(2020,04,15,15,15,00)
var t2 = Date.UTC(todayYear,todayMonth,todayDate,todayHour,todayMinute,todaySecond)
var diff = r2-t1
var diffYears = Math.floor(diff/years)
var diffDays = Math
.floor((diff / days) - diffYears * 365)
var diffHours = Math.floor((diff - (diffYears * 365 + diffDays) * days) / hours)
var diffMinutes = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours) / minutes)
var diffSeconds = Math.floor((diff - (diffYears * 365 + diffDays) * days - diffHours * hours - diffMinutes * minutes) / seconds)
document.getElementByld("lovexhjSitetime").innerHTML = "我们相恋了" + diffYears + "年" + diffDays + "天" + diffHours + "小时" + diffMinutes + "分钟" + diffSeconds + "秒啦"
}
lovexhjSitetime()

以下代码扔到 全局右侧广告

<aside class="widget_text sidebar-widget widget_custom_html fadeInUp">
<div class="textwidget custom-html-widget">
<div id="lovexhj" style="width: 100%; height: 100px; text-align: center; font-size: 1rem;">
<div id="lovexhjImage" style="width: 220px; margin: 0 auto;">
<!-- 左边的头像 -->
<img src="https://cdn1.tianli0.top/npm/picture-sianx@1.0.0/2020/09/18/ce811c68ff1b4eb9a5b6d2a784d07c31.png" alt="love" style="width: 60px; border-radius: 50%;">
<!-- 中间的图片 -->
<img src="https://cdn1.tianli0.top/npm/picture-sianx@1.0.0/2020/09/18/lovelogo%20.gif" alt="love" style="width: 60px; border-radius: 50%;">

<!-- 右边的头像 -->

<img src="https://cdn1.tianli0.top/npm/picture-sianx@1.0.0/2020/09/18/3db15cc33adda3afcdbc62e18fc8403f.png" alt="love" style="width: 60px; border-radius: 50%;"></div>
<p id="lovexhjSitetime" style="font-size: 0.8rem;    margin-top: 16px;  background: linear-gradient(to right, red, blue);-webkit-background-clip: text;color: transparent;">我们相恋了104天14小时47分钟19秒啦</p>  
</div>
</div>
</aside>

文章转自:Sianx's blog

最后修改:2022 年 08 月 11 日
如果觉得我的文章对你有用,请随意赞赏