帮我写一个html时间代码有年月日秒白色字体
时间: 2023-03-26 21:00:57 浏览: 80
好的,以下是您需要的 HTML 代码:
```html
<p style="color:white;">当前时间为:<span id="time"></span></p>
<script>
function updateTime() {
var now = new Date();
var year = now.getFullYear();
var month = now.getMonth() + 1;
var day = now.getDate();
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds();
var timeStr = year + "年" + month + "月" + day + "日 " + hour + ":" + minute + ":" + second;
document.getElementById("time").innerHTML = timeStr;
}
setInterval(updateTime, 100);
</script>
```
这段代码会在页面上显示当前时间,格式为“年月日 时分秒”,字体为白色。
相关问题
帮我写一个html时间代码有年月日时分秒星期 白色字体
好的,以下是代码:
<!DOCTYPE html>
<html>
<head>
<title>时间</title>
<style>
body {
background-color: black;
color: white;
font-size: 50px;
text-align: center;
margin-top: 200px;
}
</style>
</head>
<body>
<script>
function updateTime() {
var now = new Date();
var year = now.getFullYear();
var month = now.getMonth() + 1;
var day = now.getDate();
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds();
var weekDay = now.getDay();
var weekDays = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
var timeString = year + "年" + month + "月" + day + "日 " + hour + ":" + minute + ":" + second + " " + weekDays[weekDay];
document.body.innerHTML = timeString;
}
setInterval(updateTime, 100);
</script>
</body>
</html>
用html帮我写一个时间代码,要求有年月日时分秒星期,白色字体
好的,以下是代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>时间</title>
<style>
body {
background-color: black;
color: white;
font-size: 50px;
text-align: center;
margin-top: 200px;
}
</style>
</head>
<body>
<script>
function updateTime() {
var now = new Date();
var year = now.getFullYear();
var month = now.getMonth() + 1;
var day = now.getDate();
var hour = now.getHours();
var minute = now.getMinutes();
var second = now.getSeconds();
var week = now.getDay();
var weekArr = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'];
document.body.innerHTML = year + '年' + month + '月' + day + '日 ' + hour + ':' + minute + ':' + second + ' ' + weekArr[week];
}
setInterval(updateTime, 100);
</script>
</body>
</html>
```