-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathclock.html
31 lines (30 loc) · 824 Bytes
/
clock.html
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
<html>
<body>
<script>
window.onload = function(){getTime();} // onload window
function getTime(){
// Get Current Date
var today = new Date();
var h = today.getHours(); // Get Current Hours
if(h>12){
h-=12;
}
var m = today.getMinutes(); // Get Current Minutes
var s = today.getSeconds(); // Get Current Seconds
m = checkTime(m); // Check Minutes if less than 10 than retuen 01 - 09
s = checkTime(s); // Check Seconds if less than 10 than retuen 01 - 09
document.getElementById('showClock').innerHTML = h+':'+m+':'+s; // Return Into a Page
setInterval(function(){getTime();},1000); // This Function is Realtime Execute " getTime() " After every 1 s
}
function checkTime(i){
if(i<10){
return '0'+i;
}else{
return i;
}
}
</script>
<!--- View Result -->
<h1>Current Time is : <span id="showClock"></span></h1>
</body>
</html>