se vuoi usare la nostra libreria per la gestione del tempo, metti in un file esterno questo:
codice:
if(!window.WDL) WDL = {};
WDL.timeLibrary = true;
WDL.Dpro = Date.prototype;
WDL.Dpro.anno=function(d) {
var aD;
aD= this["get"+(this.utc?"UTC":"")+"FullYear"]().toString();
var aD = this.getFullYear().toString();
return d?aD.substr(2):aD;
}
WDL.Dpro.annoBisestile = function() {
var a;
a=this.anno()
if(a % 4 == 0 && a % 100 != 0 || a%400 == 0)return true
else return false
}
WDL.Dpro.amPm = function(g){
return this.ora()<12?g?"AM":"am":g?"PM":"pm";
}
WDL.Dpro.differenza = function(s) {
s=(!s || s.constructor!=Date)?new Date():new Date(s);
s.setTime(this.getTime()-s.getTime());
s.setFullYear(s.getFullYear()-1970);
return s;
}
WDL.Dpro.somma = function(a) {
a=(!a || a.constructor!=Date)?new Date():new Date(a);
a.setTime(this.getTime()+a.getTime());
a.setFullYear(a.getFullYear()-1970);
return a;
}
WDL.Dpro.mese=function(str){
var mO;
mO=(this["get"+(this.utc?"UTC":"")+"Month"]()+1).toString();
return str?this.mStr[mO-1]:mO<10?"0"+mO:mO.toString();
}
WDL.Dpro.giorno=function(settimana){
var gO, gS;
gO= this["get"+(this.utc?"UTC":"")+"Date"]().toString();
gS= this["get"+(this.utc?"UTC":"")+"Day"]().toString();
return settimana?this.sStr[gS]:gO<10?"0"+gO:gO
}
WDL.Dpro.giorniInMese=function(m){
m=m?m:this.getMonth()
return this.gMes[m]
}
WDL.Dpro.ora=function(aP){
var oO;
oO = this["get"+(this.utc?"UTC":"")+"Hours"]().toString();
return aP?oO%12==0?"12":oO%12:oO<10?"0"+oO:oO;
}
WDL.Dpro.minuto=function(){
var oM;
oM = this["get"+(this.utc?"UTC":"")+"Minutes"]().toString();
return oM<10?"0"+oM:oM
}
WDL.Dpro.secondo=function(){
var oS
oS =this["get"+(this.utc?"UTC":"")+"Seconds"]().toString();
return oS<10?"0"+oS:oS
}
WDL.Dpro.decimo=function(){
return this.millesimo().substr(0,1)
}
WDL.Dpro.centesimo=function(){
return this.millesimo().substr(0,2)
}
WDL.Dpro.millesimo=function(){
var om = this["get"+(this.utc?"UTC":"")+"Milliseconds"]().toString();
return om<10?"00"+om:om<100?"0"+om:om
}
WDL.Dpro.giornoAnno=function(){
cont=0
for(i=0;i<this.getMonth();i++)cont+=this.gMes[i]
cont+=this.getDate()
return cont
}
WDL.Dpro.settimanaAnno=function(){
d = new Date(this.getFullYear(),0,1)
return Math.ceil((this.giornoAnno()+d.getDay())/7)
}
WDL.Dpro.data=function(a){
frmt=new Array();
/* anno */
frmt['A']=this.anno(); // 4 cifre
frmt['a']=this.anno(true); // 2 cifre
/* mese */
frmt['M']=this.mese(); // mese a due cifre
frmt['m']=this.getMonth()+1; // mese a una cifra
frmt['L']=this.mStr[this.getMonth()]; // mese in lettere
frmt['l']=this.mStr[this.getMonth()].substring(0,3); // mese in 3 lettere
/* settimana */
frmt['Y']=this.settimanaAnno(); // settimana dell'anno in numero
frmt['W']=this.sStr[this.getDay()]; // giorno della settimana in lettere
frmt['w']=this.sStr[this.getDay()].substring(0,3); // giorno della settimana in 3 lettere
frmt['d']=this.getDay(); // giorno della settimana 1-7
/* giorno */
frmt['y']=this.giornoAnno(); // giorno dell'anno 1-365
frmt['G']=this.giorno(); // giorno del mese 2 cifre
frmt['g']=this.getDate(); // giorno del mese 1 cifra
/* ora */
frmt['o']=this.getHours(); // ora 1 cifra 0-23
frmt['O']=this.ora(); // ora 2 cifre 00-23
frmt['H']=this.ora(true); // formato AM PM 1-12
frmt['f']=this.getHours()<12?"am":"pm"; // am-pm
frmt['F']=this.getHours()<12?"AM":"PM"; // AM-PM
/* minuti */
frmt['i']=this.minuto(); // minuti 2 cifre
/* secondi */
frmt['s']=this.secondo(); // secondi 2 cifre
/* centesimi */
frmt['c']=this.centesimo(); // centesimi in 2 cifre
/* millesimi */
frmt['b']=this.millesimo(); // millesimi in 3 cifre
var ritorno="";
var i;
for(i=0;i<a.length;i++)ritorno+=(frmt[a.charAt(i)]==undefined)?a.charAt(i):frmt[a.charAt(i)]
return ritorno
}
WDL.Dpro.utc=false
WDL.Dpro.sStr=["Domenica","Lunedì","Martedì","Mercoledi","Giovedì","Venerdi","Sabato"];
WDL.Dpro.mStr =["Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"]
poi nella pagina fai
<script>
function dennis(){
ora=new Date()
document.getElementById('livello').innerHTML=ora.d ata('G/M/A O:i:s')
}
</script>
<body onload="dennis();setInterval('dennis()','1000')">
<div id="livello"></div>
</body>
come vedi il richiamo è una cavolata