io faccio così:
codice:
Date.prototype.getDateAndTime = function() {
var giorni = ["domenica", "lunedì", "martedì", "mercoledì", "giovedì", "venerdì", "sabato"];
var mesi = ["gennaio", "febbraio", "marzo", "aprile", "maggio", "giugno", "luglio", "agosto", "settembre", "ottobre", "novembre", "dicembre"];
var g = giorni[this.getDay()];
var d = this.getDate();
var mese = mesi[this.getMonth()];
var a = this.getFullYear();
var h = (h=this.getHours())<10 ? "0"+h : h;
var m = (m=this.getMinutes())<10 ? "0"+m : m;
var s = (s=this.getSeconds())<10 ? "0"+s : s;
return [g, d, mese, a].join(" ")+" - "+[h, m, s].join(" : ");
};
TextField.prototype.displayDateAndTime = function() {
clearInterval(this.dateID);
var d = new Date();
this.text = d.getDateAndTime();
this.dateID = setInterval(this, "displayDateAndTime", 1000);
};
poi creo un campo di testo chiamato per esempio "orario" e aggiungo questa riga:
codice:
orario.displayDateAndTime();
il risultato è nella mia home page.