-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
52 lines (48 loc) · 1.45 KB
/
index.html
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>时间戳转换器</title>
<style>
body {
font-family: Arial, sans-serif;
text-align: center;
margin: 50px;
}
input, button {
margin: 10px;
padding: 8px;
font-size: 16px;
}
#result {
margin-top: 20px;
font-size: 18px;
color: blue;
}
</style>
</head>
<body>
<h2>时间戳转换器</h2>
<label for="timestamp">输入时间戳(秒):</label>
<input type="number" id="timestamp" placeholder="例如 1700000000">
<button onclick="convertTimestamp()">转换</button>
<div id="result"></div>
<script>
function convertTimestamp() {
let timestamp = document.getElementById("timestamp").value;
if (!timestamp) {
alert("请输入时间戳!");
return;
}
// 确保时间戳是整数
timestamp = parseInt(timestamp);
// 转换为标准时间
let date = new Date(timestamp * 1000);
let formattedDate = date.toLocaleString();
// 显示结果
document.getElementById("result").innerHTML = "转换后的时间:" + formattedDate;
}
</script>
</body>
</html>