zoukankan      html  css  js  c++  java
  • 个人博客添加运行时间

    <script>
        function secondToDate(second) {
            if (!second) {
                return 0;
            }
            var time = new Array(0, 0, 0, 0, 0);
            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(2019, 01, 23, 11, 42, 23)).getTime() / 1000);
            var timestamp = Math.round((new Date().getTime() + 8 * 60 * 60 * 1000) / 1000);
            currentTime = secondToDate((timestamp - create_time));
            currentTimeHtml = 'Wyc‘s博客已经运行了:' + currentTime[0] + '' + currentTime[1] + ''
                    + currentTime[2] + '' + currentTime[3] + '' + currentTime[4]
                    + '';
            document.getElementById("htmer_time").innerHTML = currentTimeHtml;
        }    setInterval(setTime, 1000);
    </script>

    引用

    <span id="htmer_time" />
  • 相关阅读:
    css表格单元格间距设置
    JavaScript(js)设置输入焦点(focus)
    让div居中的方法
    Window.open()的使用
    getElementsByTagName的用法
    offsetTop获取top值
    js中indexof的使用
    jquery解析json数据
    iframe的使用
    WCF学习笔记Ⅲ
  • 原文地址:https://www.cnblogs.com/wuyongcong/p/10757598.html
Copyright © 2011-2022 走看看