Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>JavaScript Timepiece</title>
- <style type="text/css">
- #clock
- {
- border:1px solid #e4e4f5;
- margin:4px;
- padding:3px;
- font-family:Tahoma, Geneva, sans-serif;
- font-size:12px;
- width:200px;
- }
- h3
- {
- font-family:Georgia, "Times New Roman", Times, serif;
- color:#000;
- }
- hr
- {
- color:#063;
- }
- </style>
- <script type="text/javascript">
- function startClock() {
- var today = new Date();
- var h=today.getHours();
- var m=today.getMinutes();
- var s=today.getSeconds();
- m=checkTime(m);
- s=checkTime(s);
- if(h > 12)
- {
- h=h-12;
- s=s+" PM";
- } else if (h==12)
- {
- s=s+" PM";
- }
- else
- {
- s=s+" AM";
- }
- document.getElementById("clock").innerHTML = h + ":" + m + ":" + s;
- t=setTimeout('startClock()',1000);
- }
- function checkTime(i)
- {
- if(i<10)
- {
- i="0"+i;
- }
- return i;
- }
- </script>
- </head>
- <body onLoad="startClock()">
- <h3>The Time ...</h3><hr />
- <div id="clock"></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment