plik-u

Articles, Tips & Tricks, Usefull Softwares

Membuat Hari, Tanggal, Bulan, Tahun serta Waktu yang Berjalan

Membuat Hari, Tanggal, Bulan, Tahun serta Waktu yang Berjalan

Ingin membuat penanggalan seperti ini:

Ini scriptnya:
<script language="Javascript1.2">
<!–
var tags_before_clock = ""
var tags_middle_clock = ""
var tags_after_clock = ""

if(navigator.appName == "Netscape") {
document.write(‘<layer id="clock"></layer><br>’);
}

if (navigator.appVersion.indexOf("MSIE") != -1){
document.write(‘<span id="clock"></span>’);
}

DaysofWeek = new Array()
DaysofWeek[0]="Minggu"
DaysofWeek[1]="Senin"
DaysofWeek[2]="Selasa"
DaysofWeek[3]="Rabu"
DaysofWeek[4]="Kamis"
DaysofWeek[5]="Jum’at"
DaysofWeek[6]="Sabtu"

Months = new Array()
Months[0]="Januari"
Months[1]="Pebruari"
Months[2]="Maret"
Months[3]="April"
Months[4]="Mei"
Months[5]="Juni"
Months[6]="Juli"
Months[7]="Agustus"
Months[8]="September"
Months[9]="Oktober"
Months[10]="Nopember"
Months[11]="Desember"

function upclock(){
var dte = new Date();
var hrs = dte.getHours();
var min = dte.getMinutes();
var sec = dte.getSeconds();
var day = DaysofWeek[dte.getDay()]
var date = dte.getDate()
var month = Months[dte.getMonth()]
var year = dte.getFullYear()

var col = ":";
var spc = " ";
var line = "-";
var com = ",";
var apm;
var brk = "<br>";

if (hrs == 0) hrs=12;
if (hrs<=9) hrs="0"+hrs;
if (min<=9) min="0"+min;
if (sec<=9) sec="0"+sec;

if(navigator.appName == "Netscape") {
document.clock.document.write(tags_before_clock+day+com+spc+date+spc+month+spc+year+spc+line+spc+tags_middle_clock+hrs+col+min+col+sec+spc+tags_after_clock);
document.clock.document.close();
}

if (navigator.appVersion.indexOf("MSIE") != -1){
clock.innerHTML =
tags_before_clock+day+com+spc+date+spc+month+spc+year+spc+line+spc+tags_middle_clock+hrs+col+min+col+sec+spc+tags_after_clock;
}
}

setInterval("upclock()",1000);
//–>

Tempatkan script Javascript ini pada
website Anda. Kini website Anda telah memiliki penanggalan yang dinamis.

Advertisements

December 15, 2008 - Posted by | Aksesori Web / Blog | , , , ,

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: