-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtime.js
36 lines (35 loc) · 1.56 KB
/
runtime.js
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
setInterval(() => {
let create_time = Math.round(new Date('2019-04-17 00:00:00').getTime() / 1000); //在此行修改建站时间
let timestamp = Math.round((new Date().getTime()) / 1000);
let second = timestamp - create_time;
let time = new Array(0, 0, 0, 0, 0);
var nol = function(h){
return h>9?h:'0'+h;
}
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] = nol(parseInt(second / 3600));
second %= 3600;
}
if (second >= 60) {
time[3] = nol(parseInt(second / 60));
second %= 60;
}
if (second > 0) {
time[4] = nol(second);
}
if ((Number(time[2])<22) && (Number(time[2])>7)){
currentTimeHtml ="<img class='boardsign' src='hhttps://img.shields.io/badge/KD-%E5%9C%A8%E7%BA%BF%E4%B8%AD-6adea8?style=social&logo=cakephp' title='欢迎访问我的博客!~'><div id='runtime'>" + time[0] + ' YEAR ' + time[1] + ' DAYS ' + time[2] + ' : ' + time[3] + ' : ' + time[4] + '</div>';
}
else{
currentTimeHtml ="<img class='boardsign' src='https://img.shields.io/badge/KD-%E6%8C%82%E6%9C%BA%E4%B8%AD-6adea8?style=social&logo=cakephp' title='这个点了应该去睡觉啦,熬夜对身体不好哦'><div id='runtime'>" + time[0] + ' YEAR ' + time[1] + ' DAYS ' + time[2] + ' : ' + time[3] + ' : ' + time[4] + '</div>';
}
document.getElementById("workboard").innerHTML = currentTimeHtml;
}, 1000);