Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a clock 1

Status
Not open for further replies.

Tumbledry

Programmer
Joined
Mar 27, 2006
Messages
5
Location
US
Hi, I need to create a clock using this format:

"Friday March 13 2006 3:45pm"

I dont know were to start! please help!
 
yea I get the clock part, want the Month updates

(seconds < 10) ? seconds = "0" + seconds : seconds;
(minutes < 10) ? minutes = "0" + seconds : minutes;
(hours < 12) ? ampm = "AM" : ampm = "PM";
(hours > 12) ? hours = hours - 12 : hours;
(hours == 0) ? hours = 12 : hours;

thats my clock. Do I need an array?
 
ok, the clock displays the weekday, the month, year and the time.

my code displays the time in a text box. I need help with the weekday month and year.

here is my code

<html>
<head>
<script language="javascript">
<!--

function runClock() {
var timeNow = new Date();
var hours = timeNow.getHours();
var minutes = timeNow.getMinutes();
var seconds = timeNow.getSeconds();
var ampm = "";


(seconds < 10) ? seconds = "0" + seconds : seconds;
(minutes < 10) ? minutes = "0" + seconds : minutes;
(hours < 12) ? ampm = "AM" : ampm = "PM";
(hours > 12) ? hours = hours - 12 : hours;
(hours == 0) ? hours = 12 : hours;

var stringTime = " " + hours + ":" + minutes + ":" +
seconds + " " + ampm;

document.clockForm.clockBox.value = stringTime;

setTimeout("runClock()", 1000);
}




//-->




</script>
</head>


<body onLoad="runClock();">


<form name="clockForm">

The Time is ::


<input type="text" name="clockBox" size="11">


</form>

</body>
</html>
 
use the getMonth, getDate and getFullYear functions. You'll need to add a 1 to the result returned from the getMonth function, as it returns 0 for January and 11 for December.



*cLFlaVA
----------------------------
[tt]( <P> <B>)13 * (<P> <.</B>)[/tt]

[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top