PDA

View Full Version : Modify Date & Time Script



Cheng
05-03-2008, 08:20 PM
Hi.

I got this Date &Time javascript from a friend which is working fine but I would like to modify it a little but don't know how.


function tS(){ x=new Date(tN().getUTCFullYear(),tN().getUTCMonth(),tN().getUTCDate(),tN().getUTCHours(),tN().getUTCMinutes(),tN().getUTCSeconds()); x.setTime(x.getTime()+10800000); return x; }
function tN(){ return new Date(); }
function lZ(x){ return (x>9)?x:'0'+x; }
function dT(){ if(fr==0){ fr=1; document.write('<font size=2 font color=#11295D face=Verdana><b><span id="tP">'+eval(oT)+'</span></b></font>'); } document.getElementById('tP').innerHTML=eval(oT); setTimeout('dT()',1000); }
function y4(x){ return (x<500)?x+1900:x; }
var dN=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'),mN=new Array('January','February','March','April','May','June','July','August','September','October','November','December'),fr=0,oT="dN[tS().getDay()]+','+' '+tS().getDate()+'. '+mN[tS().getMonth()]+' '+y4(tS().getYear())+' '+'-'+' '+lZ(tS().getHours())+':'+lZ(tS().getMinutes())+':'+lZ(tS().getSeconds())+' '";

Just place a link in the html head like this:

<script type="text/javaScript" src="../clock.js"></script>

To call the script just place this in the html body where you want the Date & Time to show:

<script type="text/javaScript">dT();</script>

No problem to change font or font color and font size and also the language can be changed by replacing the weekdays and month in a different language.

German, French, Spanish and Dutch work except Italian even though I got the days and month right, why is that?

And my friend did sent me 3 scripts with each a different time zone.

I beleive this is the value for the time zone

GMT

x.setTime(x.getTime()+0);

GMT+2

x.setTime(x.getTime()+7200000);

GMT+3

x.setTime(x.getTime()+10800000);

How do I get more time zone values?

Also if you know why Italian won't work please let me know.

Thanks in advance,