Salve a tutti!
Premetto che ho già cercato nel forum se qualche altro utente avesse avuto il mio stesso problema, ma non ho trovato nulla di esaudiente.
Vi spiego brevemente: sto creando un sito per un'azienda che organizza viaggi, e nelle pagine dedicate alle singole nazioni, vorrei inserire l'orario corrente della capitale, come fanno su questo
sito: è vero, è stato creato in ASP, ma l'orario corrente viene ottenuto tramite questo codice JS
function showTime()
{
var offset=10;
var offsetminute=0;
if(offset<0)
{
offsetminute = (-1)*offsetminute;
}
if (!document.all&&!document.getElementById)
return;
thelement=document.getElementById?document.getElementById("tick2"):document.all.tick2;
var now = new Date();
Date.prototype.addHours = function (n){this.setHours (this.getHours () + n)}
Date.prototype.toDateString = function () {return [this.getDate(), this.getMonth() + 1, this.getFullYear()].join ('-')}
Date.prototype.toString = function () {return [this.toDateString(), this.toTimeString()].join (' ')}
now.addHours(offset);
now.setMinutes(now.getMinutes() +offsetminute);
var hours=now.getHours();
var minutes=now.getMinutes();
var seconds=now.getSeconds();
var dn='PM';
if (hours<12)
dn='AM';
if(hours>12)
hours=hours-12;
if (hours==0)
hours=12;
if (minutes<=9)
minutes='0'+minutes;
if (seconds<=9)
seconds='0'+seconds;
var ctime=' '+hours+':'+minutes+':'+seconds+' '+dn;
thelement.innerHTML=ctime;
setTimeout('showTime()',1000);
}
window.onload=showTime;
Ho provato a cercare nello JED ma non ho veramente trovato nessun plugin che simuli una cosa simile; quindi avevo pensato di sfruttare qualche plugin che ti permette di inserire manualmente il proprio codice.
Sourcerer non posso usarlo perchè la versione PHP non è la 5.3 (maledettissimo provider)...mi sono diretto quindi su
Embed Script.
Installato plugin, abilitato e inserito codice: funziona alla grande e cliccando
qui potete vederlo tranquillamente in opera.
Unica cosa che ancora stona è il fatto che, almeno per quanto riguarda la versione del sito in Italiano, quel AM-PM non si può proprio vedere: non sono un mago del JS, ma se leggo del codice più o meno sò comprendere qualcosa...ho provato a fare così
function showTime()
{
var offset=10;
var offsetminute=0;
if(offset<0)
{
offsetminute = (-1)*offsetminute;
}
if (!document.all&&!document.getElementById)
return;
thelement=document.getElementById?document.getElementById("tick2"):document.all.tick2;
var now = new Date();
Date.prototype.addHours = function (n){this.setHours (this.getHours () + n)}
Date.prototype.toDateString = function () {return [this.getDate(), this.getMonth() + 1, this.getFullYear()].join ('-')}
Date.prototype.toString = function () {return [this.toDateString(), this.toTimeString()].join (' ')}
now.addHours(offset);
now.setMinutes(now.getMinutes() +offsetminute);
var hours=now.getHours();
var minutes=now.getMinutes();
var seconds=now.getSeconds();
if (minutes<=9)
minutes='0'+minutes;
if (seconds<=9)
seconds='0'+seconds;
var ctime=' '+hours+':'+minutes+':'+seconds+';
thelement.innerHTML=ctime;
setTimeout('showTime()',1000);
}
window.onload=showTime;
ma non mi fa vedere un bel niente.
Qualche idea per bypassare questo intoppo?