- Pertama sobat buka dulu software web editor seperti adobe dreamweaver, front page atau kalau tidak punya semua buka saja notepad.
- Terus ketikkan script di bawah ini pada dokumen, gunakan mode HTML. Langsung copy paste aja biar cepet yah.
<html>
<head>
<title>Jam Digital</title>
<script type="text/javascript">
window.setTimeout("renderDate()",1);
days = new Array(
"Minggu","Senin","Selasa","Rabu","Kamis","Jum'at","Sabtu"
);
months = new Array(
"Januari","Februari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember"
);
function renderDate(){
var mydate = new Date();
var year = mydate.getYear();
if (year < 2000) {
if (document.all)
year = "19" + year;
else
year += 1900;
}
var day = mydate.getDay();
var month = mydate.getMonth();
var daym = mydate.getDate();
if (daym < 10)
daym = "0" + daym;
var hours = mydate.getHours();
var minutes = mydate.getMinutes();
var seconds = mydate.getSeconds();
var dn = "AM";
if (hours >= 12) {
dn = "PM";
hours = hours - 12;
}
if (hours == 0)
hours = 12;
if (minutes <= 9)
minutes = "0" + minutes;
if (seconds <= 9)
seconds = "0" + seconds;
document.getElementById("jam").innerHTML = "<B>"+days[day]+" "+daym+" "+months[month]+" "+year+"</B> | "+hours+":"+minutes+":"+seconds+" "+dn;
setTimeout("renderDate()",1000)
}
</script>
</head>
<body onLoad="renderDate()">
<div id="jam" style="background:#00CC33;border:1px dashed #000;padding:5px;width:auto;" align="center">
</div>
</body>
</html>
- Kalau sudah, simpan dokumen tersebut dengan nama yang sobat inginkan dan diberi ekstensi (.html) misalnya jam_digital.html
- Terakhir buka dan jalankan file yang telah sobat simpan tadi menggunakan browser.
- Jam Digital siap disajikan, selesai deh.
Tags:
Tips Blog
cara mengubah dokumen di notepad jadi .html gimana?