Choose fontsize:
Welcome, Guest. Please login or register.
Did you miss your activation email?

 

Pages: [1]   Go Down
  Print  
Author Topic: Javascript Clock  (Read 6359 times)
0 Members and 1 Guest are viewing this topic.
Regular
*

Karma: 3
Posts: 86

Graphic Addicts Member


View Profile
« on: January 26, 2006, 10:05:34 AM »
[h1]Javascript Clock[/h1]
Okay This Is My First Tut here. tested and working nicely. you may use the code to your liking. this is not that hard to build. it was rather fun
this is the beginning tags for your html document
Code:
<html>
<title></title>
<head>
<center><script language="JavaScript">
<!--
function startclock()
{
var thetime=new Date();

var nhours=thetime.getHours();
var nmins=thetime.getMinutes();
var nsecn=thetime.getSeconds();
var AorP=" ";

if (nhours>=12)
  AorP="P.M.";
else
  AorP="A.M.";

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

if (nhours==0)
nhours=12;

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

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

document.clockform.clockspot.value=nhours+":"+nmins+":"+nsecn+" "+AorP;

setTimeout('startclock()',1000);

}

//-->
</SCRIPT>
</head>
this goes into your header tags. this is where the script first fires.
this next part you would stick into the body of your page left, right , center. where ever it may be that will display you time.
Code:
<BODY onLoad="startclock()">
<FORM name="clockform">
<b>Time:</b> <INPUT TYPE="text" name="clockspot" size="10">
</form></center>
close the document with the last tags ans save as an html page
Code:
</body>
</html>

Example Page:
Click here to see an example of this script.

If you like this tutorial, please Click Here to register.

Click the link below to download the HTML file for this tutorial.
Javascript Clock HTML
« Last Edit: February 10, 2006, 07:30:27 PM by SKETCHi » Logged
Pages: [1]   Go Up
  Print  
 
Jump to:      

Flawsome [ In: 446 // Out: 1726 ] BioRUST [ In: 2951 // Out: 2428 ] Pixel-Designz [ In: 1183 // Out: 2917 ] SMF Topsites [ In: 0 // Out: 2021 ] Graphic Addicts Topsites [ In: 2435 // Out: 3389 ] cagedflame [ In: 992 // Out: 1381 ] SweDesignz [ In: 865 // Out: 1647 ] SaberFusion [ In: 553 // Out: 1622 ]
Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC
Phobos design by Bloc | XHTML | CSS


Google visited last this page Today at 06:13:17 PM