Membuat Jam,Hari, dan Tanggal dengan Javascript di Blog

Membuat Jam,Hari, dan Tanggal dengan Javascript di Blog - Setelah beberapa minggu tidak posting dikarenakan ada persiapan buat UTS, pada kes...

Membuat Jam,Hari, dan Tanggal dengan Javascript di Blog - Setelah beberapa minggu tidak posting dikarenakan ada persiapan buat UTS, pada kesempatan kali ini saya akan membahas tentang Cara Membuat Jam ,Hari, dan Tanggal dengan Javascript di Blog yang saya ambil referensi dari Blog Kang Rian. ...
jam js

Ada beberapa pilhan yang tersedia pada menu tersebut, jika anda suka silahkan lihat dan pelajari javascript dibawah ini:

1. Tanggal dengan Javascript:
Kode Javascriptnya:
<script type="text/javascript">
<!--
var months = ['Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember'];
var date = new Date();
var day = date.getDate();
var month = date.getMonth();
var yy = date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;
document.write(day + " " + months[month] + " " + year);
//-->
</script>

2. Hari dan Tanggal :
Kode Javascriptnya:
<script type='text/javascript'>
<!--
var months = ['Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember'];
var myDays = ['Minggu', 'Senin', 'Selasa', 'Rabu', 'Kamis', 'Jum&#39;at', 'Sabtu'];
var date = new Date();
var day = date.getDate();
var month = date.getMonth();
var thisDay = date.getDay(),
    thisDay = myDays[thisDay];
var yy = date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;
document.write(thisDay + ', ' + day + ' ' + months[month] + ' ' + year);
//-->
</script>

3. Jam sekarang (Pasif):
Kodenya Javascriptnya:
<script type="text/javascript">
<!--
var d = new Date();
var curr_hour = d.getHours();
var curr_min = d.getMinutes();
curr_min = curr_min + "";
if (curr_min.length == 1) {
    curr_min = "0" + curr_min;
}
document.write(curr_hour + " : " + curr_min);
//-->
</script>

4. Dengan Format AM/PM
Kode Javascriptnya:
<script type="text/javascript">
<!--
var a_p = "";
var d = new Date();
var curr_hour = d.getHours();
if (curr_hour < 12) {
    a_p = "AM";
} else {
    a_p = "PM";
}
if (curr_hour == 0) {
    curr_hour = 12;
}
if (curr_hour > 12) {
    curr_hour = curr_hour - 12;
}

var curr_min = d.getMinutes();
curr_min = curr_min + "";
if (curr_min.length == 1) {
    curr_min = "0" + curr_min;
}
document.write(curr_hour + " : " + curr_min + " " + a_p);
//-->
</script>

5. Jam Sekarang (Aktif):
Kode Javascriptnya:
<div id="clock">
</div>
<script type="text/javascript">
<!--
function showTime() {
    var a_p = "";
    var today = new Date();
    var curr_hour = today.getHours();
    var curr_minute = today.getMinutes();
    var curr_second = today.getSeconds();
    if (curr_hour < 12) {
        a_p = "AM";
    } else {
        a_p = "PM";
    }
    if (curr_hour == 0) {
        curr_hour = 12;
    }
    if (curr_hour > 12) {
        curr_hour = curr_hour - 12;
    }
    curr_hour = checkTime(curr_hour);
    curr_minute = checkTime(curr_minute);
    curr_second = checkTime(curr_second);
 document.getElementById('clock').innerHTML=curr_hour + ":" + curr_minute + ":" + curr_second + " " + a_p;
    }

function checkTime(i) {
    if (i < 10) {
        i = "0" + i;
    }
    return i;
}
setInterval(showTime, 500);
//-->
</script>
Semoga bermanfaat.

COMMENTS

BLOGGER: 62
Loading...
Name

Adsense,5,CSS,8,Font,1,HTML,5,Javascript,5,Jquery,1,Lain-lain,5,PHP,1,SEO,3,Template,45,Tips,2,Tutorial,50,Widget,1,
ltr
item
HBT Blog: Membuat Jam,Hari, dan Tanggal dengan Javascript di Blog
Membuat Jam,Hari, dan Tanggal dengan Javascript di Blog
http://1.bp.blogspot.com/-NQXB4BBZbNM/U2ay4Oz8NyI/AAAAAAAABmQ/_SF3p2X44b0/s1600/jam.gif
http://1.bp.blogspot.com/-NQXB4BBZbNM/U2ay4Oz8NyI/AAAAAAAABmQ/_SF3p2X44b0/s72-c/jam.gif
HBT Blog
http://hollabacktexas.blogspot.com/2014/05/membuat-jamhari-dan-tanggal-dengan.html
http://hollabacktexas.blogspot.com/
http://hollabacktexas.blogspot.com/
http://hollabacktexas.blogspot.com/2014/05/membuat-jamhari-dan-tanggal-dengan.html
true
4727374246882403435
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS CONTENT IS PREMIUM Please share to unlock Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy