PageSourceSearch

https://yiwen1825.github.io/js/timer.js

js yiwen1825.github.io collected 2026-10-03 10:13:05 UTC 854 bytes, 29 lines download raw bytes

1function getBlogRunningTime() {
2    const startDate = new Date("2025-04-05");
3    const currentDate = new Date();
4
5    let years = currentDate.getFullYear() - startDate.getFullYear();
6    let months = currentDate.getMonth() - startDate.getMonth();
7    let days = currentDate.getDate() - startDate.getDate();
8
9    if (days < 0) {
10        months -= 1;
11        const prevMonth = new Date(currentDate.getFullYear(), currentDate.getMonth(), 0);
12        days += prevMonth.getDate(); // 上個月的天數
13    }
14
15    if (months < 0) {
16        years -= 1;
17        months += 12;
18    }
19
20    const timerElement = document.getElementById("running-time");
21    if (timerElement) {
22        timerElement.innerHTML = `${years} 年 ${months} 月 ${days} 天`;
23    }
24}
25
26window.onload = function() {
27    getBlogRunningTime();
28    setInterval(getBlogRunningTime, 3600000);
29};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.