前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >给网站侧边栏添加恋爱计时器

给网站侧边栏添加恋爱计时器

作者头像
小胡同学
修改2023-02-05 11:33:36
3690
修改2023-02-05 11:33:36
举报
文章被收录于专栏:小胡的技术分享

如图:

代码如下:

代码语言:javascript
复制
<div class="joe_aside__item hot" style="text-align: center; color:#888; font-size: 15px; padding:10px;">
    <div style="width: 220px; margin: 0 auto;">
        <!-- 左边的头像,nk=后面填写QQ号,直接采集QQ头像 -->
        <img src="https://q1.qlogo.cn/g?b=qq&nk=2509659437&s=640" alt="love"
            style="width: 60px; border-radius: 50%;">
        <!-- 中间的图片 -->
        <img src="http://pic.ygmgo.cn/view.php/0b9b3a8c704051bea4f2a46b3689a906.gif" alt="love"
            style="width: 60px; border-radius: 50%;">
        <!-- 右边的头像,nk=后面填写QQ号,直接采集QQ头像 -->
        <img src="https://q1.qlogo.cn/g?b=qq&nk=647249809&s=640" alt="love"
            style="width: 60px; border-radius: 50%;">
    </div>
    <p id="lovepyqSitetime"></p>
    <script language=javascript>
        function lovepyqSitetime() {
            window.setTimeout("lovepyqSitetime()", 1000);
            var seconds = 1000
            var minutes = seconds * 60
            var hours = minutes * 60
            var days = hours * 24
            var years = days * 365
            var today = new Date()
            var todayYear = today.getFullYear()
            var todayMonth = today.getMonth() + 1
            var todayDate = today.getDate()
            var todayHour = today.getHours()
            var todayMinute = today.getMinutes()
            var todaySecond = today.getSeconds()
            // 时间设置
            var t1 = Date.UTC(2023, 01, 01, 22, 22, 00)   //年,月,日,时,分,秒
            var t2 = Date.UTC(todayYear, todayMonth, todayDate, todayHour, todayMinute, todaySecond)
            var diff = t2 - 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.getElementById("lovepyqSitetime").innerHTML = "我们相恋了:</br>" + diffYears + "年" + diffDays + "天" +
                diffHours + "时" + diffMinutes + "分" + diffSeconds + "秒啦"
        }
        lovepyqSitetime()
    </script>
</div>

本文系转载,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档