当前位置:网站首页>The page displays the current time in real time
The page displays the current time in real time
2022-04-23 07:45:00 【Senior salted fish~】
Knowledge points involve :
1、 Time acquisition and format setting
2、 Set operation events for labels
3、 Timer settings
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<p class="p1"></p>
<script>
// Format :2020 year 04 month 12 Japan 10:20:00 Tuesday
function format(newDate) {
var day = newDate.getDay()
var y = newDate.getFullYear()
var m = (newDate.getMonth() + 1) < 10 ? "0" + (newDate.getMonth() + 1) : (newDate.getMonth() + 1)
var d = newDate.getDate() < 10 ? "0" + newDate.getDate() : newDate.getDate()
var h = newDate.getHours() < 10 ? "0" + newDate.getHours() : newDate.getHours()
var min = newDate.getMinutes() < 10 ? "0" + newDate.getMinutes() : newDate.getMinutes()
var s = newDate.getSeconds() < 10 ? "0" + newDate.getSeconds() : newDate.getSeconds()
var dict = {
1: " One ",
2: " Two ",
3: " 3、 ... and ",
4: " Four ",
5: " 5、 ... and ",
6: " 6、 ... and ",
0: " God ",
}
//var week=[" Japan "," One "," Two "," 3、 ... and "," Four "," 5、 ... and "," 6、 ... and "]
return y + " year " + m + " month " + d + " Japan " + h + ":" + min + ":" + s + " week " + dict[day]
}
var timerId = setInterval(function(){
var newDate = new Date()
document.querySelector(".p1").textContent = format(newDate)
},1000)
</script>
</body>
</html>
design sketch : Dynamic update


版权声明
本文为[Senior salted fish~]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230623086947.html
边栏推荐
- 判断字符串首尾是否包含目标参数:startsWith()、endsWith()方法
- SAP pi / PO rfc2soap publishes RFC interface as WS example
- 9.常用函数
- Nacos / sentinel gateway current limiting and grouping (code)
- 反思 | 事件总线的局限性,组件化开发流程中通信机制的设计与实现
- redis连接出错 ERR AUTH <password> called without any password configured for the default user.
- 3. Sort statement
- Common DOS commands
- SAP 导出Excel文件打开显示:“xxx“的文件格式和扩展名不匹配。文件可能已损坏或不安全。除非您信任其来源,否则请勿打开。是否仍要打开它?
- h5本地存储数据sessionStorage、localStorage
猜你喜欢

ABAP CDS VIEW WITH ASSOCIATION示例

canvas学习第一篇

ABAP 从CDS VIEW 发布OData Service示例

How to judge whether a point is within a polygon (including complex polygons or a large number of polygons)

keytool: command not found

js之节点操作,为什么要学习节点操作

Redis connection error err auth < password > called without any password configured for the default user

int a = 1存放在哪

防抖和节流

Custom time format (yyyy-mm-dd HH: mm: SS week x)
随机推荐
js之什么是事件?事件三要素以及操作元素
如何判断点是否在多边形内(包含复杂多边形或者多边形数量很多的情况)
Two threads print odd and even numbers interactively
On BFC (block formatting context)
NPM installation stepping pit
Reflection on the systematic design of Android audio and video caching mechanism
SAP PI/PO rfc2RESTful 发布rfc接口为RESTful示例(Proxy间接法)
Implementation of MySQL persistence
canvas学习第一篇
简易随机点名抽奖(js下编写)
13. User and authority management
promise all的实现
'NPM' is not an internal or external command, nor is it a runnable program or batch file
7. sub query
Understanding of STL container
数组扁平化
Use of typescript dictionary
js之DOM学习三种创建元素的方式
js之DOM事件
移动端布局(3D转换、动画)