当前位置:网站首页>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>
边栏推荐
- In Net 6 using dotnet format formatting code
- Successfully solved: selenium common. exceptions. TimeoutException: Message: timeout: Timed out receiving message from
- How to download and use Xiaobai one click reload on the official website
- Opensea PHP development kit
- 基于SSH实现的学生成绩管理系统
- WPF uses Maui's self drawing logic
- Teach you to write non maintainable PHP code step by step
- "Daily practice, happy water" 1108 IP address invalidation
- 【Keil】ADuCM4050官方库的GPIO输出宏定义
- great! Auto like, I use pyautogui!
猜你喜欢

Working principle of asemi three-phase rectifier bridge

Rce code execution & command execution (V)

XSS (cross site script attack) summary (II)

Virtual honeypot Honeyd installation and deployment

The SQL response is slow. What are your troubleshooting ideas?

Use js to simply implement the apply, call and bind methods

Visual studio 2022 interface beautification tutorial

WPF 使用 MAUI 的自绘制逻辑

固態硬盤開盤數據恢複的方法

渗透测试-目录遍历漏洞
随机推荐
EL & JSTL (XIII)
"Daily practice, happy water" 1108 IP address invalidation
2021-10-24
Kotlin compose listens to the soft keyboard and clicks enter to submit the event
【Keil】ADuCM4050官方库的GPIO输出宏定义
How do the defi protocols perform under this round of stress test?
JDBC (IV)
Database low-end SQL query statement fragment
Visual studio 2022 interface beautification tutorial
【FLink】access closed classloader classloader. check-leaked-classloader
How micro engine uploads remote attachments
WPF 使用 MAUI 的自绘制逻辑
Heavy broadcast | phase shift method + mathematical principle derivation of multi frequency heterodyne + implementation
Startup mode of SoC verification environment
Filter & listener (XIV)
ORA-00800: soft external error
Introduction to the hardest core PWN in the whole network_ Graphic analysis
OLAP analysis engine kylin4.0
Specific operations for uploading pictures in PHP
Integrate CDN to create the ultimate service experience for customers!