Home 博客运行时间
Post
Cancel

博客运行时间

引言

毕业论文真是折磨呢。这是什么时候的文章呢,这个文件创建时间 2023.11.30 而修改时间 2022.09.18,我看不懂,但我大受震撼

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<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(2021, 11, 06, 14, 15, 19)).getTime() / 1000);
        var timestamp = Math.round((new Date().getTime() + 8 * 60 * 60 * 1000) / 1000);
        currentTime = secondToDate((timestamp - create_time));
        currentTimeHtml = 'This Blog has running: <br/>' + currentTime[0] + ' y ' + currentTime[1] + ' d '
                + currentTime[2] + ' h ' + currentTime[3] + ' m ' + currentTime[4]
                + ' s';
        document.getElementById("htmer_time").innerHTML = currentTimeHtml;
    }    setInterval(setTime, 1000);
</script>

引用

在想放入的地方加入

1
<span id="htmer_time" style="color: pink;" />

参考文章

个人博客添加运行时间 - 腾讯云开发者社区-腾讯云

This post is licensed under CC BY 4.0 by the author.

Gateway 服务网关

简单Vue项目