System Time using JavaScript

  1. <!DOCTYPE html>  
  2.   
  3. <html xmlns="http://www.w3.org/1999/xhtml">  
  4. <head runat="server">  
  5.     <title></title>  
  6.     <style type="text/css">  
  7.         .timer {  
  8.             border-width: 1px;  
  9.             text-align: center;  
  10.             font-family: Algerian;  
  11.             background-color: aqua;  
  12.             width: 130px;  
  13.             border-style: solid;  
  14.         }  
  15.     </style>  
  16. </head>  
  17. <body>  
  18.     <form id="form1" runat="server">  
  19.         <div id="timeclock" class="timer"></div>  
  20.     </form>  
  21.     <script type="text/javascript">  
  22.         function getTimeFunc() {  
  23.             //debugger;  
  24.             var timeclock = document.getElementById("timeclock");  
  25.             timeclock.innerHTML = "";  
  26.             var getcurrdate = new Date();  
  27.             var hr =  parseInt(Math.floor(getcurrdate.getHours()));  
  28.             var mi = parseInt( Math.floor(getcurrdate.getMinutes()));  
  29.             var sc = parseInt(Math.floor(getcurrdate.getSeconds()));  
  30.             var meridian = "AM"  
  31.               
  32.             if (hr > 12);  
  33.             {  
  34.                 hr = hr - 12;  
  35.                 meridian="PM"  
  36.             }  
  37.             if (hr == 0) {  
  38.                 hr = "0";  
  39.             }  
  40.            if  (hr < 10)  
  41.             {  
  42.                 hr = "0" + hr;  
  43.             }  
  44.             if (mi < 10) {  
  45.                 mi = "0" + mi;  
  46.             }  
  47.             if (sc < 10) {  
  48.                 sc = "0" + sc;  
  49.             }  
  50.             var totalTime = hr + ":" + mi + ":" + sc + " " + meridian;             
  51.             timeclock.innerHTML =totalTime;  
  52.             setTimeout(getTimeFunc, 1000);  
  53.         }  
  54.         getTimeFunc();  
  55.     </script>  
  56. </body>  
  57. </html>