Customised Javascript wall clock


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <!--By Shashikanth reddy nalabolu-->
  2. <!--Some logic has been used from other web source-->
  3.  
  4.  
  5. <html>
  6. <head>
  7. <title>(Type a title for your page here)</title>
  8. <script type="text/javascript">
  9. function display_c(){
  10. var refresh=1000; // Refresh rate in milli seconds
  11. mytime=setTimeout('display_ct()',refresh)
  12. }
  13.  
  14. function display_ct() {
  15. var strcount
  16. //var x = new Date()
  17. var d=new Date();
  18. var time=d.getHours(); //alert(time);
  19. var secondss=d.getSeconds(); //alert(secondss);
  20. var Mins=d.getMinutes();
  21.  
  22. if(time>12)
  23. {
  24. var s = "PM";
  25. }
  26. else
  27. {
  28. var s = "AM";
  29. }
  30.  
  31. var x = time+" "+":"+" "+Mins+ " "+":"+" "+secondss+" "+s;
  32.  
  33. document.getElementById('ct').innerHTML = x;
  34. tt=display_c();
  35. }
  36. </script>
  37. </head>
  38.  
  39. <body onload=display_ct();>
  40. <span id='ct' ></span>
  41.  
  42. </body>
  43.  
  44. </html>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.