Tutorials Infos - Anleitungen - Hilfe - Dreamcodes
 

Countdown 2

Ein Countdown Code in einer etwas Anspruchsvolleren Version

Script:
<?
// Change the Dates to meet your needs
$day = 1;     // Day of the countdown
$month = 1;  // Month of the countdown
$year = 2010;       // Year of the countdown
$hours_left = number_format((mktime(0,0,0,$month,$day,$year) - time())/3600, 2);
if ($hours_left > 24) {
echo "<P>There are" . number_format(($hours_left/24), 2) . " days between today & January 1, 2010";
echo "<P>There are" . $hours_left . "hours between today & January 1, 2010";
} else {
echo "<P>" . $hours_left . "hours between today & January 1, 2010";
}
// mktime is the marked time, and time() is the current time.
// 3600 is the number of seconds in an hour.
$hours_left = (mktime(0,0,0,$month,$day,$year) - time())/3600;

// number_format($hours_left, 2) restricts the number of decimal points to 2

// if there are more hours left than are in a week
if ($hours_left > 168) {
echo "<P>There are " . number_format($hours_left, 2) . " hours between today & January 1, 2010";
echo "<P>There are " . number_format(($hours_left/24), 2) . " days between today & January 1, 2010";
echo "<P>There are " . number_format(($hours_left/168), 2) . " Weeks between today & January 1, 2010";

// if there are less hours left than are in a day
} elseif ($hours_left < 24) {
echo "<P>There are " . number_format($hours_left, 2) . " hours between today & January 1, 2010";

// for everything in between - everything else.
} else {
echo "<P>There are " . number_format($hours_left, 2) . " hours between today & January 1, 2010";
echo "<P>There are " . number_format(($hours_left/24), 2) . " days between today & January 1, 2010";
}

?>

 
ID: 427
eingestellt am: 24.06.2004
Autor: OpenC
Status zum lesen: Gast
gelesen: 10541
Webseite: www.dreamcodes.com
[Drucken]