Back to top

Autore Topic: [RISOLTO]Inserire Orario corrente nella pagina di una Nazione  (Letto 1895 volte)

Offline pot79

  • Nuovo arrivato
  • *
  • Post: 29
    • Mostra profilo
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
Codice: [Seleziona]
            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='&nbsp; '+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ì


Codice: [Seleziona]
            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='&nbsp; '+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?
« Ultima modifica: 18 Dic 2012, 13:08:58 da pot79 »

Offline fasenderos

  • Appassionato
  • ***
  • Post: 326
    • Mostra profilo
Re:Inserire Orario corrente nella pagina di una Nazione
« Risposta #1 il: 18 Dic 2012, 13:05:11 »
Un idea potrebbe essere di utilizzare un modulo che ti mostra l'ora e poi crei tanti duplicati del modulo quante sono le nazioni e ne pubblichi uno per nazione (ovviamente cambiando l'ora)..
prova a vedere nel jed http://extensions.joomla.org/extensions/calendars-a-events/time/clocks
Fiscalway - Consulenza Fiscale, Contabile e del Lavoro
Forum FW - La più grande comunità fiscale online by Fiscalway

Offline pot79

  • Nuovo arrivato
  • *
  • Post: 29
    • Mostra profilo
Re:Inserire Orario corrente nella pagina di una Nazione
« Risposta #2 il: 18 Dic 2012, 13:08:26 »
Grazie fasenderos, ma ho risolto ;D

non funzionava per colpa di un apice e un + di troppo... :o


Ricapitolando, per chi dovesse averne bisogno:


1- installate un plugin che vi permetta di inserire codice JS all'interno di un contenuto (io ho usato Embed Script)


2- ricordatevi di abilitarlo


3- disabilitate l'editor di testo


4- andate all'interno del contenuto dove volete far comparire l'orario e scrivete questo codice


FORMATO 24h SENZA AM/PM
Codice: [Seleziona]
Orario a NomeCapitale:
{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();
         
          if (minutes<=9)
              minutes='0'+minutes;
          if (seconds<=9)
              seconds='0'+seconds;
          var ctime='&nbsp; '+hours+':'+minutes+':'+seconds;
          thelement.innerHTML=ctime;
          setTimeout('showTime()',1000);
         }
          window.onload=showTime; {/js}<span id="tick2"></span>


FORMATO 12h CON AM/PM
Codice: [Seleziona]
Current Time in NomeCapitale is:
{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='&nbsp; '+hours+':'+minutes+':'+seconds+' '+dn;
          thelement.innerHTML=ctime;
          setTimeout('showTime()',1000);
         }
          window.onload=showTime; {/js}<span id="tick2"></span>

NOTA BENE
la terza riga di questo codice (var offset=10;) è quella che imposta il fuso orario della nazione che state prendendo in considerazione...nel codice che vi ho scritto si riferisce all'Australia; quindi non dimenticate di impostare il giusto valore.

Ciao a tutti!!! ;)

Offline maicolstaip

  • Global Moderator
  • Instancabile
  • ********
  • Post: 17623
  • Sesso: Maschio
    • Mostra profilo
Re:[RISOLTO]Inserire Orario corrente nella pagina di una Nazione
« Risposta #3 il: 18 Dic 2012, 15:52:35 »
Ottimo lavoro pot79.
Non si risponde a PM tecnici. Postate sul forum. Grazie.

Offline pot79

  • Nuovo arrivato
  • *
  • Post: 29
    • Mostra profilo
Re:[RISOLTO]Inserire Orario corrente nella pagina di una Nazione
« Risposta #4 il: 18 Dic 2012, 18:50:05 »
Grazie maicolstaip, è un piacere ogni tanto poter dare una mano...di solito qui dentro trovo soluzioni ai miei di problemi  ;)

 



Web Design Bolzano Kreatif