Zeit bis zu einem bestimmten Datum anzeigen

Hallo!!!
Ich würde gerne auf meiner Homepage die verbleibende Zeit bis zu einem bestimmten Datum anzeigen. Das soll in Tagen, Stunden, Minuten und vielleicht Sekunden geschehen.
Allerdings soll es nicht so sein, das die Anzahl der Tage einfach in Stunden, Minuten u.s.w. umgerechnet wird. Da soll also nicht stehen: „1 Tag - 24 Stunden - 1440 Minuten…“, sondern z.B. „1 Tag - 3 Stunden - 12 Minuten…“.
Kann mir jemand das Script dafür geben? Das wäre wirklich sehr hilfreich. Danke schoneinmal.

Ciao :smile:
Stephan

www.first-moneymaker.de

Da hast Du eins. Leicht zu ersehen, woher. Ich habe es etwas angepasst, damit man die Millisekunden rattern sieht. Kannst es ja fuer Deine Beduerfnisse aendern.

Henning

Time 's running

<!–

// A Y2K realtime counter in JavaScript. Does just what it says, counts
// down in realtime to *that* day. It can be easily modified to load up a
// series of images, instead of write raw HTML. With the addition of the
// Image() method in IE4 and Netscape 3.0 and above (I think…), you could
// easily have an updating series of images instead of text. I’ll work on
// that I think.

// Copyright of this code remains solely in the grubby hands of Andy Belfield.
// Copyright © 1998. All rights reserved. Copy this script and use it on your
// own pages freely, just keep the references to me intact, please. Failure to
// do so can result in a loss of personal Karma and you’re likely to come back
// as a slug in your next life. You have been warned.

// You can email me at [email protected]

function TheEndOfTheWorld () {

setTimeout(„TheEndOfTheWorld()“,50);

with (Math) {

// I’m pretty sure this code for the date/time is accurate. Maths/stats isn’t
// my strong point so don’t quote me on it when your machine dies a day early
// or something like that.

var currentDate = new Date();
// var doomDate = new Date(„May 9, 2000“);
var doomDate = new Date(2000, 4, 9, 9, 0, 0);
var totalSeconds = (doomDate.getTime() - currentDate.getTime()) / 1000;
var totalSecondsHH = (doomDate.getTime() - currentDate.getTime()) / 1000;
var i = totalSeconds % 86400;
var nDays = floor((totalSeconds - i) / 86400);
var x = floor(nDays % 7);
var nWeeks = floor(nDays / 7);
nDays = x;
x = floor(i % 3600);
var nHours = floor((i - x) / 3600);
var nSecs = floor(x % 60);
var nMins = floor((x - nSecs) / 60);
}

var sWeeks = new String (nWeeks);
var sDays = new String (nDays);
var sHours = new String (nHours);
var sMins = new String (nMins);
var sSecs = new String (nSecs);

var sTheEndOfTheWorld = sWeeks

// tidy things up a little

if (sWeeks == „1“) {
sTheEndOfTheWorld += " Woche "
}
else {
sTheEndOfTheWorld += " Wochen "
}

sTheEndOfTheWorld += sDays

if (sDays == „1“) {
sTheEndOfTheWorld += " Tag "
}
else {
sTheEndOfTheWorld += " Tage "
}

sTheEndOfTheWorld += sHours

if (sHours == „1“) {
sTheEndOfTheWorld += " Stunde "
}
else {
sTheEndOfTheWorld += " Stunden "
}

sTheEndOfTheWorld += sMins

if (sMins == „1“) {
sTheEndOfTheWorld += " Minute"
}
else {
sTheEndOfTheWorld += " Minuten"
}

if (sSecs == „1“) {
sTheEndOfTheWorld += " und " + sSecs + " Sekunde";
}
else {
sTheEndOfTheWorld += " und " + sSecs + " Sekunden";
}

document.TheEndOfTheWorldForm.elements[0].value = sTheEndOfTheWorld;
document.TheEndOfTheWorldForm.elements[1].value = totalSecondsHH;
}
//–>

Uh - oh . . .

Ja, Azubis jetzt geht’s langsam ab:

(in Sekunden.Millisekunden, zählt so schön)

bis zum 09. Mai 2000, 09:00 Uhr morgens

und dann beginnt die Abschlussprüfung !

Also strengt Euch an, damit das 'nen Einser gibt - and don’t loose your ambitions !  :wink: