随着时间的增加,秒数也在变化。
这是使用js+html做的,可能会影响一点运行速度,可能不会,我也不知道。
这里我分享给大家具体实现方法,需要的就可以放在自己的网站上了。
注意
如果主题设置中找到个性化页脚内容设置框,直接把代码放进去即可,位置自己调整。
如果没有,那就放在主题的footer.php里边合适位置!
网站已运行:<span id="run_time" style="color: black;"></span><script>function runTime() { var d = new Date(), str = ''; BirthDay = new Date("2018-06-14"); today = new Date(); timeold = (today.getTime() - BirthDay.getTime()); sectimeold = timeold / 1000 secondsold = Math.floor(sectimeold); msPerDay = 24 * 60 * 60 * 1000 msPerYear = 365 * 24 * 60 * 60 * 1000 e_daysold = timeold / msPerDay e_yearsold = timeold / msPerYear daysold = Math.floor(e_daysold); yearsold = Math.floor(e_yearsold); //str = yearsold + "年"; str += daysold + "天"; str += d.getHours() + '时'; str += d.getMinutes() + '分'; str += d.getSeconds() + '秒'; return str;}setInterval(function () { $('#run_time').html(runTime())}, 1000);</script>
文章版权声明:除非注明,否则均为猫屋博客MAOWUO.CN原创文章,转载或复制请以超链接形式并注明出处。
还没有评论,来说两句吧...