Total members 11890 |It is currently Sat Apr 20, 2024 7:26 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





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>




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : print clock using JavaScript
 Simple Clock using Date class and Threading     -  
 Help for Print using php     -  
 Print the ASCII Set     -  
 Print all MySQL status value     -  
 Print all files in a directory     -  
 Difference between PHP echo() and PHP print()?     -  
 Print all server variables     -  
 How to print a webcam picture in Jsp     -  
 Get union of two arrays set and print it     -  
 print element in 2d matrix     -  



Topic Tags

JavaScript Time
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com