当前位置:网站首页>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>
边栏推荐
- PHP calls map API
- Customize the console plot result style
- What if win11 Bluetooth fails to connect? Solution of win11 Bluetooth unable to connect
- How micro engine uploads remote attachments
- How PHP gets the user's City
- 【FLink】access closed classloader classloader.check-leaked-classloader
- Vscade setting clang format
- Write shell script error summary
- IronOCR 2022.1 Crack
- CSRF (Cross Site Request Forgery) &ssrf (server request forgery) (IV)
猜你喜欢

Records of ros2/dds/qos/ topics

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

"Daily practice, happy water" 1108 IP address invalidation

Which programming language is the most cumbersome to implement Hello world?

File upload vulnerability (III)

执行SQL响应比较慢,你有哪些排查思路?

ASEMI大功率场效应管和三极管的区别

Startup mode of SoC verification environment

Heavy broadcast | phase shift method + mathematical principle derivation of multi frequency heterodyne + implementation

以太网是什么要怎么连接电脑
随机推荐
渗透测试-目录遍历漏洞
MySQL concept and operation (III)
olap分析引擎——Kylin4.0
Triangle class (construction and deconstruction)
Google Earth engine (GEE) - Global jrc/gsw1_ 1 / batch download of yearlyhistory dataset (China region)
Why PHP is not safe
多睡觉,能减肥,芝加哥大学最新研究:每天多睡1小时,等于少吃一根炸鸡腿...
2021-10-24
MySQL prevents Chinese garbled code and solves the problem of Chinese garbled code
Ctfhub eggs
【Keil】ADuCM4050官方库的GPIO输出宏定义
Region of Halcon: generation of multiple regions (3)
Web3 DApp用户体验最佳实践
PHP calls map API
Chapter IX app project test (2) test tools
ASEMI大功率场效应管和三极管的区别
【图像融合】基于matlab方向离散余弦变换和主成分分析图像融合【含Matlab源码 1907期】
win11蓝牙无法连接怎么办?win11蓝牙无法连接的解决方法
Visual studio 2022 interface beautification tutorial
IronOCR 2022.1 Crack