Total members 10262 | Gratitudes |It is currently Wed May 23, 2012 8:27 pm Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Code Snippet
 Code subject: print clock using JavaScript
PostPosted: Fri Sep 16, 2011 11:39 pm 
Offline
Mastermind
User avatar

Joined: Tue Mar 27, 2007 10:55 pm
Posts: 2279
Location: Earth
Has thanked: 39 time
Have thanks: 61 time

Time clock using JavaScript
Code:

<html>
<
title>java script clock</title>
<
head>
<
script language="JavaScript">
<!--

function showClock()
{
var thetime=new Date();

var hoursCounter=thetime.getHours();
var minutesCounter=thetime.getMinutes();
var secondsCounter=thetime.getSeconds();
var dayCounter=thetime.getDay();
var monthCounter=thetime.getMonth();
var todayDate=thetime.getDate();
var yearCounter=thetime.getYear();
var AM_PM=" ";

if (hoursCounter>=12)
    AM_PM="PM.";
else
    AM_PM="AM.";

if (hoursCounter>=13)
    hoursCounter-=12;

if (hoursCounter==0)
   hoursCounter=12;

if (secondsCounter<10)
 secondsCounter="0"+secondsCounter;

if (minutesCounter<10)
 minutesCounter="0"+minutesCounter;

if (dayCounter==0)
  dayCounter="SudayCounter";
if (dayCounter==1)
  dayCounter="ModayCounter";
if (dayCounter==2)
  dayCounter="Tuesday";
if (dayCounter==3)
  dayCounter="Wednesday";
if (dayCounter==4)
  dayCounter="Thursday";
if (dayCounter==5)
  dayCounter="Friday";
if (dayCounter==6)
  dayCounter="Saturday";

monthCounter+=1;

if (yearCounter<=99)
  yearCounter= "19"+yearCounter;

if ((yearCounter>99) && (yearCounter<2000))
 yearCounter+=1900;

document.getElementById("timediv").innerHTML=hoursCounter+": "+
minutesCounter+": "+secondsCounter+" "+AM_PM+" "+dayCounter+", "+monthCounter+"/"+todayDate+"/"+yearCounter;
// sleep for one second
setTimeout('showClock()',1000);

}
 

//-->
</script>
</head>

<body>

<table> 
<tr>
<td>Time:</td><td><div id="timediv" /></td>
</tr>
 </table>
<SCRIPT language="JavaScript">
<!--
showClock();
//-->
</SCRIPT>

</body>
</HTML>

_________________
Currenlty programming with : java , html , php , and javascript . (OCJP-6 certified )


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 1 post ] 
Quick reply


  

 Similar topics
 JavaScript fade out problem
 javascript read file
 getting gst, pst total to diplay in my javascript form
 need help with javascript
 Javascript select menu validation issue
 validate age entered as selection box in javascript
 Trim string in JavaScript
 check array contains a value using javascript
 Javascript Multi-dimensional Arrays
 using javascript

All times are UTC [ DST ]


Users browsing similar codes

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Code Snippet | Next Code Snippet 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team