当前位置:网站首页>JS how to get the date
JS how to get the date
2022-06-12 04:51:00 【MuQing】
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<div id="box"> Time </div>
<button onclick="data(1)"> Show year </button>
<button onclick="data(2)"> Show month </button>
<button onclick="data(3)"> Display time </button>
</body>
</html>
<script>
function data(a){
var d=new Date(); // Set a date object represented by a string
if(a==1){
yy=d.getFullYear(); // Take full year
document.getElementById('box').innerHTML=yy+' year '
}else if(a==2){
mm=d.getMonth()+1; // Take the month
document.getElementById('box').innerHTML=mm+' month '
}else if(a==3){
intHours = d.getHours();
intMinutes = d.getMinutes();
intSeconds = d.getSeconds();
document.getElementById('box').innerHTML=intHours+':'+intMinutes+':'+intSeconds
}
}
</script>边栏推荐
- IC验证中的force/release 学习整理(6)研究对 wire 类型信号的影响
- Install/Remove of the Service Denied!
- When the build When gradle does not load the dependencies, and you need to add a download path in libraries, the path in gradle is not a direct downloadable path
- CCF access control system
- Pytorch was reported by a large number of netizens that torchrec, a new library, was "born" and has a large scale
- 【C语言】实现字符串截取功能
- 【cjson】根节点注意事项
- leetcode 205. Isomorphic Strings
- Simple Tetris
- 2022 examination questions and online simulation examination for safety management personnel of hazardous chemical business units
猜你喜欢
随机推荐
2022 self study materials for Zhejiang computer level III network and security technology examination (1) (updated on 2.28)
Summary of common interview questions in redis
PostgreSQL age XID maintenance prevents the database from being read-only
Map coordinate conversion of Baidu map API
The master programmer "plays" a C program that is not like C
Sentinel-2 data introduction and download
EnterpriseTECH STAR Question
[backtracking method] backtracking method to solve the problem of Full Permutation
Surface net radiation flux data, solar radiation data, rainfall data, air temperature data, sunshine duration, water vapor pressure distribution, wind speed and direction data, surface temperature
Unable to resolve dependency tree
Memory protection
2022 electrician (elementary) operation certificate examination question bank and online simulation examination
In the era of smart retail, Weimeng reshapes the value of "shopping guide"
C# Task. Waitall method
Detailed explanation of Command Execution Vulnerability
Soil type, soil texture, soil nutrient and change data, soil organic matter, soil pH, soil nitrogen, phosphorus and potassium
Difference between thread and task
Oracle's instr()
Day18 creation and restoration of sparse array
asp. Net core theme Middleware








