Would like to do this w/o JS
Posted: Mon Apr 04, 2005 8:18 am
Hi All:
This script:
has two PHP codes in the source, they set timezone and daypart (am/pm) the rest is handled by JavaScript. This is a dynamic clock (meaning it actually runs on the page)... I have been unable to get this to happen using PHP but would like to. The question is: "How do we do something this dynamic?"
The JS works fine, but with only two points where PHP code is inserted, I figure it might as well be completely JS or I need to find a way to do this same effect in PHP proper.
Thanks for any suggestions.
This script:
Code: Select all
<body>
<div align="e;center"e;>
<font size="e;3"e; color="e;#009999"e;><b>
<span id="e;clock"e;>
<SCRIPT LANGUAGE="e;JavaScript"e;>
<!--
function getTheDate(){
var dayArray=new Array("e;Sunday"e;,"e;Monday"e;,"e;Tuesday"e;,"e;Wednesday"e;,"e;Thursday"e;,"e;Friday"e;,"e;Saturday"e;)
var monthArray=new Array("e;January"e;,"e;February"e;,"e;March"e;,"e;April"e;,"e;May"e;,"e;June"e;,"e;July"e;,"e;August"e;,"e;September"e;,"e;October"e;,"e;November"e;,"e;December"e;)
var myDate=new Date()
var year=myDate.getYear()
if (year < 1000)
year+=1900
var day=myDate.getDay()
var month=myDate.getMonth()
var dayNum=myDate.getDate()
if (dayNum<10)
dayNum="e;0"e;+dayNum
var year=myDate.getYear()
if (year < 1000)
year+=1900
var day=myDate.getDay()
var month=myDate.getMonth()
var dayNum=myDate.getDate()
var hours=myDate.getHours()
var minutes=myDate.getMinutes()
var seconds=myDate.getSeconds()
var dn="e;AM"e;
var tzone="e;Central Daylight Time"e;
if (hours==0)
hours=12
if (minutes<=9)
minutes="e;0"e;+minutes
if (seconds<=9)
seconds="e;0"e;+seconds
var cdate=dayArrayїday]+"e;, "e;+monthArrayїmonth]+"e; "e;+dayNum+"e;, "e;+year+"e; | "e;+hours+"e;:"e;+minutes+"e;:"e;+seconds+"e; "e;+dn+"e; ("e;+tzone+"e;)"e;
if (document.all)
document.all.clock.innerHTML=cdate
else if (document.getElementById)
document.getElementById("e;clock"e;).innerHTML=cdate
else
document.write(cdate)
}
if (!document.all&&!document.getElementById)
getTheDate()
function goforit(){
if (document.all||document.getElementById)
setInterval("e;getTheDate()"e;,1000)
}
window.onload=goforit()
// End -->
</script>
</span>
</b>
</font>
</div>
</body>The JS works fine, but with only two points where PHP code is inserted, I figure it might as well be completely JS or I need to find a way to do this same effect in PHP proper.
Thanks for any suggestions.