PDA

View Full Version : A Basic Code For A Clock :P



Sam
17-09-2005, 02:03 PM
<html>

<head>

</head>
<body onLoad="goforit()">
<script>



var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday")
var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")

function getthedate(){
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var hours=mydate.getHours()
var minutes=mydate.getMinutes()
var seconds=mydate.getSeconds()
var dn="AM"
if (hours>=12)
dn="PM"
if (hours>12){
hours=hours-12
}
if (hours==0)
hours=12
if (minutes<=9)
minutes="0"+minutes
if (seconds<=9)
seconds="0"+seconds
//change font size here
var cdate="<small><font color='000000' face='Arial'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+" "+hours+":"+minutes+":"+seconds+" "+dn
+"</b></font></small>"
if (document.all)
document.all.clock.innerHTML=cdate
else if (document.getElementById)
document.getElementById("clock").innerHTML=cdate
else
document.write(cdate)
}
if (!document.all&&!document.getElementById)
getthedate()
function goforit(){
if (document.all||document.getElementById)
setInterval("getthedate()",1000)
}

</script>
<span id="clock"></span>

</body>

</html>

icebox12
17-09-2005, 02:04 PM
I'll test it now..

Good work I think

--
Regards

EDIT = 900th Post :eusa_danc

RYANNNNN
17-09-2005, 02:05 PM
Alot of code is not needed, looks like you ripped it.

Anderman
17-09-2005, 02:05 PM
Why not just use

1. For the time script

<?PHP echo date("H:i:s"); ?>

2. For the date script

<?PHP echo date("d/m/y"); ?>

Sam
17-09-2005, 02:07 PM
I didnt rip it :s Its How i make Clocks i dont know any other way, If there is s simpler way plz tell me how lmao, i also have an affliates sysyem code which xEnigma gave me with the layout i bought

icebox12
17-09-2005, 02:09 PM
Yes it works but I do agree with the others to rather a long script... Try shortening it down :s

Sam
17-09-2005, 02:10 PM
i have an affliates code which xenigma gave me wen i bought a layout off him

Anderman
17-09-2005, 05:56 PM
You cant shoten javascript 4fs
And who cares if its long, Its not as if you see any of it

Sam
17-09-2005, 08:28 PM
I was Being Sarcastic In my Post ''/

Want to hide these adverts? Register an account for free!