-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
48 lines (45 loc) · 1.28 KB
/
main.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
const todayDate = new Date();
var currentHour = Number(todayDate.getHours());
var currentMin = Number(todayDate.getMinutes());
var currentSec = Number(todayDate.getSeconds());
var outputHour = document.getElementById("outputHour");
var outputMin = document.getElementById("outputMin");
var outputSec = document.getElementById("outputSec");
outputHour.innerHTML = FormatTime(currentHour) + '<small>h</small>';;
outputMin.innerHTML = FormatTime(currentMin) + '<small>m</small>';;
outputSec.innerHTML = FormatTime(currentSec) + '<small>s</small>';
var countId = setInterval(myClock,1000);
function myClock()
{
currentSec++;
if(currentSec == 60)
{
currentSec = 0;
currentMin++;
if(currentMin == 60)
{
currentMin = 0;
currentHour++;
}
outputMin.innerHTML = FormatTime(currentMin) + '<small>m</small>';
}
outputSec.innerHTML = FormatTime(currentSec) + '<small>s</small>'
if(currentHour == 24)
{
currentHour = 0;
}
outputHour.innerHTML = FormatTime(currentHour) + '<small>h</small>';
}
function FormatTime(time)
{
var formatedTime
if(time < 10)
{
formatedTime = "0" + time.toString();
}
else
{
formatedTime = time.toString();
}
return formatedTime
}