This is a small and very simple tutorial on how to create a clock for your website usingĀ javascript.Just add the below code to the section of your website where you want the clock to be displayed
<span id="clock"></span>
<script type="text/javascript">
{
function startclock()//script from mistonline.in
var thetime=new Date();
var nhours=thetime.getHours();
var nmins=thetime.getMinutes();
var nsecn=thetime.getSeconds();
var nday=thetime.getDay();
var nmonth=thetime.getMonth();
var ntoday=thetime.getDate();
var nyear=thetime.getYear();
var AorP = (nhours >= 12) ? "P.M." : "A.M.";
if (nhours>=13)
nhours-=12;
if (nhours<1)
nhours=12;
if (nsecn<10)
nsecn="0"+nsecn;
if (nmins<10)
nmins="0"+nmins;
switch (nday) {
case 0 : nday = "Sunday"; break;
case 1 : nday = "Monday"; break;
case 2 : nday = "Tuesday"; break;
case 3 : nday = "Wednesday"; break;
case 4 : nday = "Thursday"; break;
case 5 : nday = "Friday"; break;
case 6 : nday = "Saturday"; break;
}
nmonth+=1;
if (nyear< =99)
nyear= "19"+nyear;
if ((nyear>99) && (nyear<2000))
nyear+=1900;
var clock_span = document.getElementById("clock");
clock_span.innerHTML = nhours+":"+nmins+":"+nsecn+" "+AorP+" "+nday+", "+nmonth+"/"+ntoday+"/"+nyear;
setTimeout('startclock()',1000);
}
if (document.getElementById && document.createTextNode) {
startclock();
}
</script>
Thanks ![]()
Incoming search terms:
- simple javascript clock (18)
- simple php clock (8)
- jquery clock tutorial (6)
- jquery simple clock (6)
- simple clock script jquery (5)
- ajax clock tutorial (4)
- php jquery clock (3)
- php clock tutorial (3)
- PHP simple clock script (2)
- javascript clock tutorial (2)
- tiny javascript clock (2)
- simple javascript clock script (2)
- php simple jquery clock (1)
- php jquery simple clock (1)
- simple clock script (1)
- simple clock php script (1)
- simple clock java script (1)
- php script of clock (1)
- simple clock (1)
- simple clock in javascript (1)
- simple javascript clock code (1)
- website clock script (1)
- solution javascript and ajax tutorial 4 case 1 (1)
- small simple clock code (1)
- small java clock (1)
- simplest javascript clock (1)
- Simplel javascript clock (1)
- simple web clock code (1)
- simple php clock jquery (1)
- simple jquery clock with php (1)
- simple javascript tips (1)
- Simple Javascript clock php (1)
- writing a jquery clock (1)
- php javascript simple clock (1)
- javascript clock for my website (1)
- javascript and ajax tutorial tutorial 5 case 3 (1)
- java clock 6 (1)
- image clock scripts (1)
- image clock javascript (1)
- how to make a simple javascript clock (1)
You will also be interested in ,
- Slide in and out animate div vertically using jquery
- Block key press using javascript
- Alert a message before leaving a web page using javascript
- Javascript Countdown Script
- Give a welcome alert message to your visitors using javascript
- Load webpage dynamically from query string using simple javascript and iframe
- Javascript popup window
- Simple message slideshow news ticker using javascript
- Disable browser back button using javascript
- DOM elements dynamically using our JAVASCRIPT

