Skip to content

Commit

Permalink
Update main.js
Browse files Browse the repository at this point in the history
  • Loading branch information
BlueBoy247 committed Dec 31, 2024
1 parent 8fde49f commit 6e9b240
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ fetch(apiUrl)
.then(data => {
const gitHubUpdateTime = data.pushed_at;
const date = new Date(gitHubUpdateTime);
const utc8Date = new Date(date.getTime() + 8 * 60 * 60 * 1000);
const formattedDate = `${utc8Date.getFullYear()}/${String(utc8Date.getMonth() + 1).padStart(2, '0')}/${String(utc8Date.getDate()).padStart(2, '0')} ${String(utc8Date.getUTCHours()).padStart(2, '0')}:${String(utc8Date.getUTCMinutes()).padStart(2, '0')}:${String(utc8Date.getUTCSeconds()).padStart(2, '0')} (UTC+8)`;

let timezone = date.getTimezoneOffset() / -60;
if(timezone > 0){
timezone = `+${timezone}`;
}else{
timezone = `${timezone}`;
}
const formattedDate = `${date.getFullYear()}/${String(date.getMonth() + 1).padStart(2, '0')}/${String(date.getDate()).padStart(2, '0')} ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}:${String(date.getSeconds()).padStart(2, '0')} (UTC${timezone})`;
lastupdatetime.innerText = formattedDate;
})
.catch(error => {
Expand Down

0 comments on commit 6e9b240

Please sign in to comment.