-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
49 lines (36 loc) · 1.18 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function currentTime(){
const myDate = new Date();
const hr = myDate.getHours();
const min = myDate.getMinutes();
const sec = myDate.getSeconds();
const month = myDate.getMonth();
const year = myDate.getFullYear()
const date = myDate.getDate();
const months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
if(hr>12){
document.getElementById('hours').innerText = hr-12;
}
else if(hr<12){
document.getElementById('hours').innerText = hr;
}
for(let i=0;i<=month;i++){
if(month == i){
document.getElementById('month').innerText = months[i];
}
}
if(min<10){
document.getElementById('minutes').innerText = "0"+min;
}
else{
document.getElementById('minutes').innerText = min;
}
if(sec<10){
document.getElementById('seconds').innerText = "0"+sec
}
else{
document.getElementById('seconds').innerText = sec;
}
document.getElementById('year').innerText = year;
document.getElementById('date').innerText = date;
}
setInterval(currentTime, 10);