添加时间显示

This commit is contained in:
张梦南 2025-03-29 21:58:38 +08:00
parent dfce476a0e
commit bcec51fae6
3 changed files with 37 additions and 26 deletions

View File

@ -5,3 +5,24 @@ body, html {
font-family: Arial, sans-serif; /* 默认字体 */
background-color:#f4f4f4;
}
/*主内容区test*/
.container {
width: 60%;
margin: 10% auto 0;
background-color: #f0f0f0;
padding: 2% 5%;
border-radius: 10px
}
ul {
padding-left: 20px;
}
ul li {
line-height: 2.3
}
a {
color: #20a53a
}

View File

@ -3,31 +3,8 @@
<head>
<meta charset="utf-8">
<title>DreamLife|HomePage</title>
<link rel="stylesheet" href="homepage/css/footer.css">
<link rel="stylesheet" href="homepage/css/body.css">
<style>
.container {
width: 60%;
margin: 10% auto 0;
background-color: #f0f0f0;
padding: 2% 5%;
border-radius: 10px
}
ul {
padding-left: 20px;
}
ul li {
line-height: 2.3
}
a {
color: #20a53a
}
</style>
<link rel="stylesheet" href="css/footer.css">
<link rel="stylesheet" href="css/body.css">
</head>
<body>
@ -40,11 +17,15 @@
<li>目前网站工具箱以基本完善</li>
<li>工具箱网站dreamlife.top/toolbox</li>
</ul>
<h2>您的当前区域时间</h2>
<p id="timeDisplay">加载中...</p>
</div>
<footer>
<p>&copy; 2025 DreamLife 版权所有</p>
</footer>
<script src="javascape/time.js"></script>
</body>
</html>

9
javascape/time.js Normal file
View File

@ -0,0 +1,9 @@
//获取计算机的时间信息
function updateLocalTime() {
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
const now = new Date().toLocaleString('zh-CN', { timeZone: timezone });
document.getElementById('timeDisplay').innerText = `当前时间 (${timezone}): ${now}`;
}
setInterval(updateLocalTime, 1000); // 每秒更新时间
window.onload = updateLocalTime;