网站页脚显示运行时长(x年x天x日)

wp教程评论2.2K views阅读模式

网站页脚显示运行时长(x年x天x日)演示,字体颜色可以自定义变化

网站页脚显示运行时长(x年x天x日)

可以直接将此代码添加到指定位置,分为展示代码和js代码。

  1. &gt;&gt;&gt;网站已平稳运行: <span id="momk"> <span id="htmer_time"></span></span>&lt;&lt;&lt; <script> function secondToDate(second) { if (!second) { return 0; } var time = new Array(00000); if (second >= 365 * 24 * 3600) { time[0] = parseInt(second / (365 * 24 * 3600)); second %= 365 * 24 * 3600; } if (second >= 24 * 3600) { time[1] = parseInt(second / (24 * 3600)); second %= 24 * 3600; } if (second >= 3600) { time[2] = parseInt(second / 3600); second %= 3600; } if (second >= 60) { time[3] = parseInt(second / 60); second %= 60; } if (second > 0) { time[4] = second; } return time; } </script> <script type="text/javascript" language="javascript"> function setTime() { var create_time = Math.round(new Date(Date.UTC(20170809001)).getTime() / 1000); var timestamp = Math.round((new Date().getTime() + 8 * 60 * 60 * 1000) / 1000); currentTime = secondToDate((timestamp - create_time)); currentTimeHtml = currentTime[0] + '年' + currentTime[1] + '天' + currentTime[2] + '时' + currentTime[3] + '分' + currentTime[4] + '秒'; document.getElementById("htmer_time").innerHTML = currentTimeHtml; } setInterval(setTime, 1000); </script> <!--结束-->

字体颜色样式css

/*底部时间换颜色*/
.breadcrumb{border-width:1px;  
background-color:rgb(255, 255, 255);  
margin-Bottom:5px;border-radius:2px;margin-top:5px;}  

#momk{animation:change 10s infinite;font-weight:800; }
@keyframes change{0%{color:#5cb85c;}25%{color:#556bd8;}50%{color:#e40707;}75%{color:#66e616;}100% {color:#67bd31;}}



以上全部完成

展示代码:放在指定位置即可

&gt;&gt;&gt;网站已平稳运行: <span id="momk"> <span id="htmer_time"></span></span>&lt;&lt;&lt;

 

企鹅SEO
  • 本文由 发表于 2021年7月27日 18:12:03
  • 转载请务必保留本文链接:https://www.qieseo.com/449458.html

发表评论