Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!doctype html>
- <html>
- <head>
- <title>Javascript Clock</title>
- <script type="text/javascript">
- function startTimer()
- {
- var today=new Date();
- var h=today.getHours();
- var m=today.getMinutes();
- var s=today.getSeconds();
- var timeOfDay = ( h < 12 ) ? "AM" : "PM";
- h = ( h > 12 ) ? h - 12 : h;
- m=checkclock(m);
- s=checkclock(s);
- document.getElementById('clock').innerHTML=h+":"+m+":"+s;
- document.getElementById('info').innerHTML=timeOfDay;
- t=setTimeout('startTimer()',500);
- }
- function checkclock(i)
- {
- if (i<10)
- {
- i="0" + i;
- }
- return i;
- }
- </script>
- <style type="text/css">
- body {background-color: #242424;}
- #clock {
- color: #EFEFEF;
- font-family: sans, Impact, Arial, monospace;
- font-size: 200px;
- text-align: center;
- }
- #info {
- color: #EFEFEF;
- font-family: sans, Impact, Arial, monospace;
- font-size: 50px;
- text-align: center;
- margin-left: 1000px;
- margin-top: -95px;
- }
- p {
- color: #EFEFEF;
- font-family: sans, Impact, Arial, monospace;
- font-size: 24px;
- margin-right: 620px;
- text-align: center;
- margin-top: 200px;
- }
- </style>
- </head>
- <body onload="startTimer()">
- <p>The Current Time Is:</p><div id="clock"></div><div id="info"></div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment