wordpress主题显示运行时间

之前我一直想数据库有没有记录WordPress的创建时间,绕了一大圈才焕然大悟,如果只是自己的网站,像这些配置可以写死。如果是公司的话可以酌情考虑。我直接在显示页面添加如下代码:

<script>
    function runtime() {
        window.setTimeout("runtime()", 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()
        var todayDate = today.getDate()
        var todayHour = today.getHours()
        var todayMinute = today.getMinutes()
        var todaySecond = today.getSeconds()
        /* Date.UTC() -- 返回date对象距世界标准时间(UTC)1970年1月1日午夜之间的毫秒数(时间戳) year - 作为date对象的年份,
          为4位年份值 month - 0-11之间的整数,做为date对象的月份 day - 1-31之间的整数,做为date对象的天数 hours - 0(午夜24点)-23之间的整数,
          做为date对象的小时数 minutes - 0-59之间的整数,做为date对象的分钟数 seconds - 0-59之间的整数,做为date对象的秒数 microseconds - 0-999之间的整数,
         做为date对象的毫秒数 */
        var t1 = Date.UTC(2011, 4, 1, 1, 1, 1)
        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("runtime").innerHTML = " 本站已运行" + diffYears + " 年 " + diffDays + " 天 " + diffHours + " 小时 " + diffMinutes + " 分钟 " + diffSeconds + " 秒"
    }
    runtime()
   </script>
  <p><span id="runtime" style="color: #523f6d"></span></p>

无意间看到日期的code,如下

<div class="top-time">  
   <?php echo date('Y年m月d日'); ?>  
   <?php $weekarray=array("日","一","二","三","四","五","六"); echo "星期".$weekarray[date("w")]; ?> 
 </div>

小提示:

git log 退出 按q。

git rest –hard HEAD-hash  回到指定的版本。

0 条评论
发表一条评论