-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrunTime.js
26 lines (26 loc) · 1.11 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
//用途: 紀錄網站架站開始時間
function NewDate(str) {
str = str.split('-');
var date = new Date();
date.setUTCFullYear(str[0], str[1] - 1, str[2]);
date.setUTCHours(0, 0, 0, 0);
return date;
}
function ageCalc() {
var hellowWorld = "本站已誕生" + daysold + "天" + hrsold + "小時" + minsold + "分" + seconds + "秒";
var birthDay = NewDate("2021-07-25");
var today = new Date();
var timeold = today.getTime() - birthDay.getTime();
var sectimeold = timeold / 1000
var secondsold = Math.floor(sectimeold);
var msPerDay = 24 * 60 * 60 * 1000;
var e_daysold = timeold / msPerDay;
var daysold = Math.floor(e_daysold);
var e_hrsold = (daysold - e_daysold) * -24;
var hrsold = Math.floor(e_hrsold);
var e_minsold = (hrsold - e_hrsold) * -60;
var minsold = Math.floor((hrsold - e_hrsold) * -60); var seconds = Math.floor((minsold - e_minsold) * -60).toString();
document.getElementById("hellowWorld").innerHTML = "本站已誕生" + daysold + "天" + hrsold + "小時" + minsold + "分" + seconds + "秒";
setTimeout(ageCalc, 1000);
}
ageCalc();