Countdown läuft falsch
#1
Hallo, vielleicht könnt ihr mir ja hier weiterhelfen. Ich habe mir dieses Countdownscript eingebaut. Leider ändert es Mittags um 14:00 h den Tag. Könnt ihr mir sagen woran es liegen kann? Hier hab ich es eingebaut:
http://www.tobias-regner.music.de

Danke schon mal

Hier der Link für die Beschreibung:
http://www.onetwomax.de/magazin/7704/Cou...bseite.htm

Hier der Code:

<html>
<head>
<title>CountDown-Script</title>
<script language="JavaScript" type="text/javascript">

function CountDown() {
var Tsecond = 0; // Zielsekunden
var Tminute = 0; // Zielminuten
var Thour = 0; // Zielstunden
var Tday = 24; // Zieltag
var Tmonth = 12; // Zielmonat
var Tyear = 2005; // Zieljahr
var howlong = "";

var target = new Date(Tyear, Tmonth-1, Tday, Thour, Tminute, Tsecond);
target = target.getTime();
var now = new Date();
now = now.getTime();
var diff = target - now;

var years = (diff - (diff % 31557600000)) / 31557600000;
diff = diff - (years * 31557600000);
var months = (diff - (diff % 2628000000)) / 2628000000;
diff = diff - (months * 2628000000);
var days = (diff - (diff % 86400000)) / 86400000;
diff = diff - (days * 86400000);
var hours = (diff - (diff % 3600000)) / 3600000;
diff = diff - (hours * 3600000);
var minutes = (diff - (diff % 60000)) / 60000;
diff = diff - (minutes * 60000);
var seconds = (diff - (diff % 1000)) / 1000;

if(seconds > -1) {
if (years != 0)
{
howlong = years+" Jahr";
if (years > 1) howlong = howlong+"e";
}
if (months != 0)
{
howlong = howlong + " " + months+" Monat";
if (months > 1) howlong = howlong + "e";
}
if (days != 0)
{
howlong = howlong + " " + days+" Tag";
if (days > 1) howlong = howlong + "e";
}
if (hours != 0)
{
howlong = howlong + " " + hours+" Stunde";
if (hours > 1) howlong = howlong + "n";
}
if (minutes != 0)
{
howlong = howlong + " " + minutes+" Minute";
if (minutes > 1) howlong = howlong + "n";
}
if (seconds != 0)
{
howlong = howlong + " " + seconds+" Sekunde";
if (seconds > 1) howlong = howlong + "n";
}
setTimeout("CountDown()",1000);
} else {
howlong = "Ziel erreicht!!!";
}

document.CountDown.diff.value = howlong;
}
</script>
</head>
<body onLoad="CountDown()">
<form name="CountDown"><table width="450" border="1" cellspacing="0" cellpadding="2">
<tr>
<td width="100">Fanclubtreffen in Teisendorf in:</td>
<td><div align="center">
<input type="text" name="diff" size="50">
</div></td>
</tr>
</table>
</form>
</body>
</html>
  Zitieren
#2
Eine Frage, ohne jetzt näher auf das Script einzugehen.
Ist das Zieljahr so gewollt?
var Tyear = 2005; // Zieljahr

Ich denke 2006 ist da besser oder? Smile
  Zitieren
#3
Im Einbau stehts ja auf 2006... Habs nur hier im original reingestellt....
  Zitieren
#4
ich habe mir das script wo anders nochmal runtergeladen.
Es klappt jetzt... keine ahnung woran der fehler lag. Trotzdem mal dankeschön...
  Zitieren
#5
Sehr merkwürdig. Na hauptsache klappt es jetzt. Evtl. kannst du noch die Adresse hier reinstellen. Vielleicht sucht der ein oder andere danach Smile
  Zitieren
#6
Die Adresse hab ich nimmer... schäm... aber den funktionierenden Code:

<html>
<head>
<title>CountDown-Script</title>
<script language="JavaScript" type="text/javascript">

function CountDown() {
var Tsecond = 0; // Zielsekunden
var Tminute = 0; // Zielminuten
var Thour = 10; // Zielstunden
var Tday = 16; // Zieltag
var Tmonth = 09; // Zielmonat
var Tyear = 2006; // Zieljahr
var howlong = "";

var target = new Date(Tyear, Tmonth-1, Tday, Thour, Tminute, Tsecond);
target = target.getTime();
var now = new Date();
now = now.getTime();
var diff = target - now;

var years = (diff - (diff % 31557600000)) / 31557600000;
diff = diff - (years * 31557600000);
var months = (diff - (diff % 2628000000)) / 2628000000;
diff = diff - (months * 2628000000);
var days = (diff - (diff % 86400000)) / 86400000;
diff = diff - (days * 86400000);
var hours = (diff - (diff % 3600000)) / 3600000;
diff = diff - (hours * 3600000);
var minutes = (diff - (diff % 60000)) / 60000;
diff = diff - (minutes * 60000);
var seconds = (diff - (diff % 1000)) / 1000;

if(seconds > -1) {
if (years != 0)
{
howlong = years+" Jahr";
if (years > 1) howlong = howlong+"e";
}
if (months != 0)
{
howlong = howlong + " " + months+" Monat";
if (months > 1) howlong = howlong + "e";
}
if (days != 0)
{
howlong = howlong + " " + days+" Tag";
if (days > 1) howlong = howlong + "e";
}
if (hours != 0)
{
howlong = howlong + " " + hours+" Stunde";
if (hours > 1) howlong = howlong + "n";
}
if (minutes != 0)
{
howlong = howlong + " " + minutes+" Minute";
if (minutes > 1) howlong = howlong + "n";
}
if (seconds != 0)
{
howlong = howlong + " " + seconds+" Sekunde";
if (seconds > 1) howlong = howlong + "n";
}
setTimeout("CountDown()",1000);
} else {
howlong = "Sie ist da!";
}

document.CountDown.diff.value = howlong;
}
</script>
</head>
<body onLoad="CountDown()">
<form name="CountDown"><table width="450" border="1" cellspacing="0" cellpadding="2">
<tr>
<td width="110">bis zum Fanclubtreffen in Teisendorf</td>
<td><div align="center">
<input type="text" name="diff" size="60">
</div></td>
</tr>
</table>
</form>
</body>
</html>
  Zitieren


Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 3 Gast/Gäste