当前位置:网站首页>Page electronic clock (use js to dynamically obtain time display)
Page electronic clock (use js to dynamically obtain time display)
2022-06-25 05:02:00 【Dai Sensen】
effect

Code
<style>
h2 {
text-align: center;
}
</style>
<script>
window.addEventListener('load', function() {
var h2 = document.querySelector('h2');
time();
var timer = setInterval(time, 1000);
function time() {
var date = new Date();
Y = date.getFullYear();
console.log(Y);
M = date.getMonth() + 1;
console.log(M);
D = date.getDate();
console.log(D);
W = date.getDay();
switch (W) {
case 0:
W = " Japan ";
break;
case 1:
W = " One ";
break;
case 2:
W = " Two ";
break;
case 3:
W = " 3、 ... and ";
break;
case 4:
W = " Four ";
break;
case 5:
W = " 5、 ... and ";
break;
case 6:
W = " 6、 ... and ";
break;
}
console.log(W);
var h = date.getHours();
h = h < 10 ? '0' + h : h;
console.log(h);
var m = date.getMinutes();
m = m < 10 ? '0' + m : m;
console.log(m);
var s = date.getSeconds();
s = s < 10 ? '0' + s : s;
console.log(s);
console.log('========');
h2.innerHTML = Y + " year " + M + ' month ' + D + ' Sunday and Sunday ' + W + " " + h + ':' + m + ':' + s;
}
});
</script>
</head>
<body>
<h2>123</h2>
</body>
边栏推荐
- Apache+php uploading large files
- Successfully solved: selenium common. exceptions. TimeoutException: Message: timeout: Timed out receiving message from
- Calculate student grade (virtual function and polymorphism)
- 【FLink】access closed classloader classloader.check-leaked-classloader
- buuctf(pwn)
- 《QDebug 2022年6月》
- Integrate CDN to create the ultimate service experience for customers!
- MySQL concept and operation (III)
- Startup mode of SoC verification environment
- Notes on non replacement elements in the line (padding, margin, and border)
猜你喜欢

win11蓝牙无法连接怎么办?win11蓝牙无法连接的解决方法

TX Text Control 30.0 ActiveX

Go deep into the working principle of browser and JS engine (V8 engine as an example)

Efficient NoSQL database service Amazon dynamodb experience sharing

Leader: who can use redis expired monitoring to close orders and get out of here!

成功解决:selenium.common.exceptions.TimeoutException: Message: timeout: Timed out receiving message from

Introduction to the hardest core PWN in the whole network_ Graphic analysis

How to use the Magic pig system reinstallation master

《QDebug 2022年6月》

Startup mode of SoC verification environment
随机推荐
File upload vulnerability (III)
台式电脑连不上wifi怎么办
基于SSH实现的学生成绩管理系统
API interface management setup -eolinker4.0
SOC验证环境的启动方式
【Flink】RocksDB增量模式checkpoint大小持续增长的问题及解决
绝了!自动点赞,我用 PyAutoGUI!
Chapter IX app project test (2) test tools
Basic knowledge of web pages (URL related)
《QDebug 2022年6月》
【FLink】access closed classloader classloader.check-leaked-classloader
初识 Flutter 的绘图组件 — CustomPaint
OLAP analysis engine kylin4.0
Ctfhub eggs
Separation of storage and computing in Dahua cloud native database
parallel recovery slave next change & parallel recovery push change
Creation and use of MySQL index
WPF uses Maui's self drawing logic
Detailed summary of position positioning
Method of opening data recovery of solid state disk