当前位置:网站首页>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>
边栏推荐
- At the age of 30, I began to learn programming by myself. Is it still time for me to have difficulties at home?
- WPF 使用 MAUI 的自绘制逻辑
- Write shell script error summary
- XSS (cross site script attack) summary (II)
- Matlab notes
- [relax's law of life lying on the square] those poisonous chicken soup that seem to be too light and too heavy, but think carefully and fear
- In Net 6 using dotnet format formatting code
- Construction scheme of distributed websocket
- 基于Cortex-M3、M4的精准延时(系统定时器SysTick延时,可用于STM32、ADuCM4050等)
- Detailed summary of position positioning
猜你喜欢
Heavy broadcast | phase shift method + mathematical principle derivation of multi frequency heterodyne + implementation
Qdebug June 2022
Svg code snippet of loading animation
Ctfhub eggs
How do the defi protocols perform under this round of stress test?
How to open the DWG file of the computer
Why is the TCP handshake just 3 times?
固態硬盤開盤數據恢複的方法
In Net 6 using dotnet format formatting code
Ranorex Studio 10.1 Crack
随机推荐
Heavy broadcast | phase shift method + mathematical principle derivation of multi frequency heterodyne + implementation
Why does the SQL statement hit the index faster than it does not?
Creation and use of MySQL index
Web3 DAPP user experience best practices
Which programming language is the most cumbersome to implement Hello world?
初识 Flutter 的绘图组件 — CustomPaint
Records of ros2/dds/qos/ topics
Opensea PHP development kit
Successfully solved: selenium common. exceptions. TimeoutException: Message: timeout: Timed out receiving message from
olap分析引擎——Kylin4.0
Visual studio 2022 interface beautification tutorial
In Net 6 using dotnet format formatting code
Use serialize in egg to read and write split tables
Eyeshot Ultimate 2022 Crack By Xacker
parallel recovery slave next change & parallel recovery push change
Google Earth engine (GEE) - Global jrc/gsw1_ 1 / batch download of yearlyhistory dataset (China region)
本轮压力测试下,DeFi协议们表现如何?
Summary of SQL injection (I)
Implementation of websocket long connection by workman under laravel
Codeforces Round #802 (Div. 2) C D