Originariamente inviato da br1
Frase incomprensibile...
Ma che dici? mese e' numerico mentre l'elemento dell'array nameMth[now.getMonth()] e' alfabetico...
Ricordati che prima hai impostato
var mese = now.getMonth();
per cui avresti anche potuto scrivere
nameMth[mese]
Bene, ho risolto tutto, data e ora, ho messo anche il css, ma c'è un ultima cosa: a video l'ora appare sotto la data, mentre dovrebbe apparire a fianco visto che li richiamo in linea
Codice PHP:
<div id="data-ora">
<script type="text/javascript">data();</script><div id="txt"></div>
</div>
Codice PHP:
function data() {
var now = new Date();
var giornsett = now.getDay();
var giorno = now.getDate();
var mese = now.getMonth();
var anno = now.getFullYear();
if (giorno<=9) { giorno='0'+giorno; }
var nameDay = new Array('domenica','lunedì','martedì','mercoledì','giovedì','venerdì','sabato');
var nameMth = new Array('gennaio','febbraio','marzo','aprile','maggio','giugno','luglio','agosto', 'settembre','ottobre','novembre’,‘dicembre');
document.write(' '+ nameDay[giornsett] + ' ' + giorno + ' ' + nameMth[mese] + ' ' + anno + ' ');
}
function startTime() {
var today = new Date();
var ora = today.getHours();
var minuti = today.getMinutes();
var secondi = today.getSeconds();
var minuti = checkTime(minuti);
var secondi = checkTime(secondi);
var t = setTimeout(function() { startTime() },1000);
document.getElementById('txt').innerHTML = ora + ':' + minuti + ':' + secondi;
}
function checkTime(i) {
if (i<10) {
i = '0' + i;
}
return i;
}