-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclock.php
71 lines (64 loc) · 2.16 KB
/
clock.php
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="css/clock.css">
</head>
<body onload="initClock()">
<!--digital clock start-->
<div class="datetime">
<div class="date">
<span id="dayname">Day</span>,
<span id="month">Month</span>
<span id="daynum">00</span>,
<span id="year">Year</span>
</div>
<div class="time">
<span id="hour">00</span>:
<span id="minutes">00</span>:
<span id="seconds">00</span>
<span id="period">Pagi</span>
</div>
</div>
<!--digital clock end-->
<script type="text/javascript">
function updateClock(){
var now = new Date();
var dname = now.getDay(),
mon = now.getMonth(),
dnum = now.getDate(),
yr = now.getFullYear(),
hour = now.getHours(),
min = now.getMinutes(),
sec = now.getSeconds(),
pesan = "";
if(hour >= 0 && hour <12){
pesan = "Selamat Pagi";
}
if(hour >= 12 && hour <18){
pesan = "Selamat Siang";
}
if(hour >= 18 && hour <24){
pesan = "Selamat Malam";
}
Number.prototype.pad = function(digits){
for(var n = this.toString(); n.length < digits; n = 0 + n);
return n;
}
var months = ["Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"];
var week = ["Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jum'at", "Sabtu"];
var ids = ["dayname", "month", "daynum", "year", "hour", "minutes", "seconds", "period"];
var values = [week[dname], months[mon], dnum.pad(2), yr, hour.pad(2), min.pad(2), sec.pad(2), pesan];
for(var i = 0; i < ids.length; i++)
document.getElementById(ids[i]).firstChild.nodeValue = values[i];
}
function initClock(){
updateClock();
window.setInterval("updateClock()", 1);
}
</script>
</body>
</html>