markusgo1967
Lt. Commander
- Registriert
- März 2009
- Beiträge
- 1.334
Hallo,
habe mir ein Script "ausgeborgt" und es für meine Zwecke modifiziert.
Läuft soweit auch, nur hätte ich gerne beide Termine als Countdown ausgegeben mit einem Absatz zwischen diesen, also ungefahr so:
bis zum Tag X sind es noch x Tage x Std x Min. X Sek.
bis zum Tag Y sind es noch Y Tage Y Std Y Min. Y Sek.
Leider wird nur der erste Termin angezeigt!
und nun der Code:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="author" content="Patrick Saar" />
<title>PHP Countdown</title>
</head>
<body>
<div id="countdown" style=" font-family: Arial', monospace; font-size: 8 pt; margin-top: 15px;">
<?php
$endTime = array();
$text = array();
$endTime[] = mktime(17, 0, 0, 12, 14, 2013); //Stunde, Minute, Sekunde, Monat, Tag, Jahr;
$text[] = 'zur Weihnachtsfeier im HQ';
$endTime[] = mktime(13, 0, 0, 5, 29, 2014); //Stunde, Minute, Sekunde, Monat, Tag, Jahr;
$text[] = 'zum Clantreffen in Falkensee';
$count_i = 0;
$timeNow = time(true);
while(($endTime[$count_i] - $timeNow) < 0) {
$count_i++;
}
$diffTime = $endTime[$count_i] - $timeNow;
//Berechnung fuer Tage, Stunden, Minuten
if($diffTime >= 0) {
$countdown_d = floor($diffTime / 86400);
$diffTime = $diffTime % 86400;
$countdown_h = floor($diffTime / 3600);
$diffTime = $diffTime % 3600;
$countdown_m = floor($diffTime / 60);
$countdown_s = $diffTime % 60;
//Formatierung
$tage = 'Tage';
if($countdown_s < 10) $countdown_s = '0'.$countdown_s;
if($countdown_m < 10) $countdown_m = '0'.$countdown_m;
if($countdown_h < 10) $countdown_h = '0'.$countdown_h;
if($countdown_d == 1) $tage = 'Tag';
echo '<B>'.$countdown_d.'</b> '.$tage.' und<B> '.$countdown_h.'</b> Std.<B> '.$countdown_m.' </b>Min.<B> '.$countdown_s.'</b> Sek. bis '.$text[$count_i];
}
?>
</div>
</body>
</html>
Besten Dank
Markus
habe mir ein Script "ausgeborgt" und es für meine Zwecke modifiziert.
Läuft soweit auch, nur hätte ich gerne beide Termine als Countdown ausgegeben mit einem Absatz zwischen diesen, also ungefahr so:
bis zum Tag X sind es noch x Tage x Std x Min. X Sek.
bis zum Tag Y sind es noch Y Tage Y Std Y Min. Y Sek.
Leider wird nur der erste Termin angezeigt!
und nun der Code:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="author" content="Patrick Saar" />
<title>PHP Countdown</title>
</head>
<body>
<div id="countdown" style=" font-family: Arial', monospace; font-size: 8 pt; margin-top: 15px;">
<?php
$endTime = array();
$text = array();
$endTime[] = mktime(17, 0, 0, 12, 14, 2013); //Stunde, Minute, Sekunde, Monat, Tag, Jahr;
$text[] = 'zur Weihnachtsfeier im HQ';
$endTime[] = mktime(13, 0, 0, 5, 29, 2014); //Stunde, Minute, Sekunde, Monat, Tag, Jahr;
$text[] = 'zum Clantreffen in Falkensee';
$count_i = 0;
$timeNow = time(true);
while(($endTime[$count_i] - $timeNow) < 0) {
$count_i++;
}
$diffTime = $endTime[$count_i] - $timeNow;
//Berechnung fuer Tage, Stunden, Minuten
if($diffTime >= 0) {
$countdown_d = floor($diffTime / 86400);
$diffTime = $diffTime % 86400;
$countdown_h = floor($diffTime / 3600);
$diffTime = $diffTime % 3600;
$countdown_m = floor($diffTime / 60);
$countdown_s = $diffTime % 60;
//Formatierung
$tage = 'Tage';
if($countdown_s < 10) $countdown_s = '0'.$countdown_s;
if($countdown_m < 10) $countdown_m = '0'.$countdown_m;
if($countdown_h < 10) $countdown_h = '0'.$countdown_h;
if($countdown_d == 1) $tage = 'Tag';
echo '<B>'.$countdown_d.'</b> '.$tage.' und<B> '.$countdown_h.'</b> Std.<B> '.$countdown_m.' </b>Min.<B> '.$countdown_s.'</b> Sek. bis '.$text[$count_i];
}
?>
</div>
</body>
</html>
Besten Dank
Markus