KD-one: Datumsfunktion + create.textNode

Beitrag lesen

Hallo,

Ich habe folgendes Script, das nur im IE lief, für Geckos umgebaut:

<script type="text/javascript">
<!--
function xtime()
{
today = new Date();
day=today.getDate();
month=today.getMonth()+1;
year=today.getYear();
hour=today.getHours();
minutes=today.getMinutes();
seconds=today.getSeconds();

if (day < 10) {day="0"+day;}
if (month < 10) {month="0"+month;}
if (minutes < 10) {minutes="0"+minutes;}
if (seconds < 10) {seconds="0"+seconds;}
timeString= day + "." + month + "." + year + " " + hour + ":" + minutes + ":" + seconds;
ticktack.innerHTML = timeString;
window.setTimeout("xtime();", 100);}
window.onload = xtime;
//-->
</script>

Der relevante Teil sieht nun so aus und läuft auch grundsätzlich:

<script type="text/javascript">
<!--
function xtime()
{
[..........................nicht geänderte Angaben....................]
timeString= day + "." + month + "." + year + "   -   " + hour + ":" + minutes + ":" + seconds;
if (document.all)
{ticktack.innerHTML = timeString;}
else if(window.opera || (document.getElementById && !document.all))
{var timeString = document.createTextNode(day + "." + month + "." + year + "   -   " + hour + ":" + minutes + ":" + seconds);
document.getElementById('ticktack').appendChild(timeString);}
window.setTimeout("xtime();", 100);}
window.onload = xtime;
//-->
</script>

Nun treten aber 2 Probleme auf:
Erstens werden die geschützten Leerzeichen im timestring codiert, also als Klartext ausgegeben, und zweitens wird das Jahr nicht als 2003(wie im IE), sondern als 103 ausgegeben.
Kann mir bei den beiden Problemen jemand auf die Sprünge helfen?

Gruß

Kurt

--
grüne Idylle:"Wozu brauchen wir Kraftwerke, Strom kommt doch aus der Steckdose..."
http://faq.united-web.at
http://elektro-dunzinger.at
http://shop.elektro-dunzinger.at