Author
Message
assasyn New Member Joined: Jul 21, 2005 Posts: 2
Posted:
Wed Jul 20, 2005 11:08 pm
Hi all,
I have some code that displays the current time and date in various time zones around Australia which I would like to put into my PHP-Nuke site.
This is the code (Taken from MaxxBlade's clock):
<html>
<body>
<table width="43%" border="0">
<tr>
<td width="21%">NSW, QLD, VIC, TAS </td>
<td width="79%"><span id="tP1">tP1</span></td>
</tr>
<tr>
<td>SA, NT </td>
<td><span id="tP2">tP2</span></td>
</tr>
<tr>
<td>WA</td>
<td><span id="tP3">tP3</span></td>
</tr>
</table>
<scri pt type="text/javasc ript">
func tion tN(){
return new Date();
}
fun ction lZ(x){
return (x>9)?x:'0'+x;
}
func tion fY2(x){
x=(x<500)?x+1900:x;
return String(x).substring(2,4);
}
func tion tS(offs){
x=new Date(tN().getUTCFullYear(),tN().getUTCMonth(),tN().getUTCDate(),tN().getUTCHours(),tN().getUTCMinutes(),tN().getUTCSeconds());
x.setTime(x.getTime()+offs);
return x;
}
func tion dS(){
return ((tN().getTime()>fD(0,3,1,1).getTime())&&(tN().getTime()<fD(0,9,1,-1).getTime()))?3600000:0;
}
fun ction fD(d,m,h,p){
var week=(p<0)?7*(p+1):7*(p-1),nm=(p<0)?m+1:m,x=new Date(tN().getUTCFullYear(),nm,1,h,0,0),dOff=0;
if(p<0){
x.setTime(x.getTime()-86400000);
}
if(x.getDay()!=d){
dOff=(x.getDay()<d)?(d-x.getDay()):0-(x.getDay()-d);
if(p<0&&dOff>0){
week-=7;
}
if(p>0&&dOff<0){
week+=7;
}
x.setTime(x.getTime()+((dOff+week)*86400000));
}
return x;
}
fun ction tN(){ return new Date(); }
fun ction dS(){ return ((tN().getTime()>fD(0,9,1,-1).getTime())&&(tN().getTime()<fD(0,2,1,-1).getTime()))?3600000:0; }
fun ction fD(d,m,h,p){ var week=(p<0)?7*(p+1):7*(p-1),nm=(p<0)?m+1:m,x=new Date(tN().getUTCFullYear(),nm,1,h,0,0),dOff=0; if(p<0){ x.setTime(x.getTime()-86400000); } if(x.getDay()!=d){ dOff=(x.getDay()<d)?(d-x.getDay()):0-(x.getDay()-d); if(p<0&&dOff>0){ week-=7; } if(p>0&&dOff<0){ week+=7; } x.setTime(x.getTime()+((dOff+week)*86400000)); } return x; }
fun ction dT(){
// Clock #1
offs=dS()+36000000;
tP1.innerText=eval("dN[tS(offs).getDay()]+' '+tS(offs).getDate()+' '+mN[tS(offs).getMonth()]+' '+fY2(tS(offs).getYear())+' '+'::'+' '+lZ(tS(offs).getHours())+':'+lZ(tS(offs).getMinutes())+':'+lZ(tS(offs).getSeconds())");
// Clock #2
offs=dS()+34200000;
tP2.innerText=eval("dN[tS(offs).getDay()]+' '+tS(offs).getDate()+' '+mN[tS(offs).getMonth()]+' '+fY2(tS(offs).getYear())+' '+'::'+' '+lZ(tS(offs).getHours())+':'+lZ(tS(offs).getMinutes())+':'+lZ(tS(offs).getSeconds())");
// Clock #3
offs=28800000;
tP3.innerText=eval("dN[tS(offs).getDay()]+' '+tS(offs).getDate()+' '+mN[tS(offs).getMonth()]+' '+fY2(tS(offs).getYear())+' '+'::'+' '+lZ(tS(offs).getHours())+':'+lZ(tS(offs).getMinutes())+':'+lZ(tS(offs).getSeconds())");
setTimeout('dT()',1000);
}
var dN=new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
var mN=new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
if(!document.all){
window.onload=dT;
}else{
dT();
}
</s cript>
</body>
</html>
Now it all works fine as a stand alone page, but when I try to add it to the nuke site I get an error about the tags not being allowed.
Id there anyway I can convert this code into either a block or a module as I would like to display it on the main page somewhere.
Sorry if this has been asked before but I'm at work and trying not to get busted surfing the net
hitwalker Sells PC To Pay For Divorce Joined: Posts: 5661
Posted:
Thu Jul 21, 2005 6:46 am
well adding the java script stuff isnt a great idea.
also you should take out the body and html tags .
You can try to create in block admin an empty block and then via phpmyadmin add the java script stuff in that block by hand.
assasyn New Member Joined: Jul 21, 2005 Posts: 2
Posted:
Thu Jul 21, 2005 8:07 pm
Got it working thanks
pan Involved Joined: Jul 25, 2006 Posts: 354
Posted:
Wed Mar 11, 2009 9:08 pm
Can someone explain this so I can try to do it?
View next topic
View previous topic
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum