-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
51 lines (42 loc) · 1.35 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
50
51
function setTime(){
var dateTime = new Date();
var hours = dateTime.getHours();
var minutes = dateTime.getMinutes();
var seconds = dateTime.getSeconds();
var day = dateTime.getDate();
var years = dateTime.getFullYear();
var am_pm = document.getElementById("am-Pm");
var month_name = ["January", "February", "March",
"April", "May", "June", "July", "August",
"September", "October", "November", "December"];
var month = dateTime.getMonth();
var monthName = month_name[month];
if(hours >= 12){
am_pm.innerHTML = "PM";
}else{
am_pm.innerHTML = "AM";
}
if (hours > 12){
hours = hours - 12;
}
if (hours < 10){
hours = "0" + hours;
}
if (minutes < 10){
minutes = "0" + minutes;
}
if (seconds < 10){
seconds = "0" + seconds;
}
if (date < 10){
date = "0" + date ;
}
document.getElementById("day").innerHTML = day;
document.getElementById("monthName").innerHTML = monthName;
document.getElementById("dayName").innerHTML = dayName;
document.getElementById("years").innerHTML = years;
document.getElementById("hours").innerHTML = hours;
document.getElementById("minutes").innerHTML = minutes;
document.getElementById("seconds").innerHTML = seconds;
}
setInterval(setTime, 1000);