当前位置:网站首页>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>边栏推荐
- The emergence of new ides and the crisis of programmers?
- Oracle paging query ~~rownum (line number)
- Advanced MySQL knowledge points (7)
- Why is Julia so popular?
- Solid programming concepts
- C# TaskFactory. Startnew method
- MFC General dialog color dialog
- Let me tell you the benefits of code refactoring
- How to count the total length of roads in the region and draw data histogram
- Bearpi IOT serial port transceiver 1- normal mode
猜你喜欢
![[wechat applet] the mobile terminal selects and publishes pictures](/img/9a/46bc4a7bf9b70d26b0e24fe02f747d.jpg)
[wechat applet] the mobile terminal selects and publishes pictures

C asynchronous programming (async and await) and asynchronous method synchronous invocation

2022 electrician (elementary) operation certificate examination question bank and online simulation examination

How to deploy PostgreSQL as a docker container

Operation of simulated examination platform for 2022 safety officer-b certificate examination questions

Map coordinate conversion of Baidu map API

How to count the total length of roads in the region and draw data histogram

Microsoft announces that it will discontinue support for older versions of visual studio

Simple Tetris

Ubunt 20.04 uses CDROM or ISO as the installation source
随机推荐
New year news of osdu open underground data space Forum
Let me tell you the benefits of code refactoring
1006 next spread
Drive safety coding & troubleshooting guide
Radiometric calibration and atmospheric correction of sentry 2 L1C multispectral data using sen2cor
mysqld: Can‘t create directory ‘D: oftinstall\mysql57 (Errcode: 2 - No such file or directory)
JWT learning and use
Jwt Learning and use
2022 "college entrance examination memory" has been packaged, please check!
JWT學習與使用
Microsoft announces that it will discontinue support for older versions of visual studio
Some problems of silly girl solved
Simple Tetris
Memory protection
Question for the 3D printing lattice?
Realease package appears – missing type parameter
【C语言】实现字符串截取功能
[backtracking method] backtracking method to solve the problem of Full Permutation
kali下安装pycharm并创建快捷访问
QT compiling security video monitoring system 44 video uploading