< Buzzing or vibrating the login form using jquery Posted On May 15, 2012 : 0 comments << >> Simple div slideshow using jquery Posted On May 9, 2012 : 0 comments << >> Copy mysql column in varchar to type date Posted On May 3, 2012 : 0 comments << >> Enter only numbers inside a input field of a form using javascript Posted On May 1, 2012 : 0 comments << >> Slide in and out animate div vertically using jquery Posted On April 25, 2012 : 1 comment << >> Tag cloud using php, mysql and ajax with filter Posted On April 24, 2012 : 0 comments << >> Change webpage font color or background color from the user side using javascript Posted On April 19, 2012 : 0 comments << >> A single link that cycles through several webpage background color using javascript Posted On April 17, 2012 : 0 comments << >> Simple webpage redirection using perl script Posted On April 10, 2012 : 0 comments << >> Get ipaddress using perl script Posted On April 4, 2012 : 0 comments << >>

Simple Javascript Clock

This Tutorial Has Been Viewed 1,623 Times.
VN:F [1.9.17_1161]
Rating: 10.0/10 (2 votes cast)

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&lt;1)
   nhours=12;
  if (nsecn&lt;10)
   nsecn="0"+nsecn;
  if (nmins&lt;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&lt;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 :)

VN:F [1.9.17_1161]
Rating: 10.0/10 (2 votes cast)

Simple Javascript Clock, 10.0 out of 10 based on 2 ratings

Incoming search terms:





You will also be interested in ,

Leave a Reply

Proudly designed by Mistonline.in.
Affordable Seo PackagesSeo BlogEdu Backlinks