#native_company# #native_desc#
#native_cta#

countdown script

By Juergen Boese
on December 11, 2004

Version: 1.0

Type: Full Script

Category: Calendars/Dates

License: GNU General Public License

Description: displays time left until an event will occur using text and numbers; easy to use; can be adapted to your needs

<?php

    //////////////////////////////////////////////////////////////////////////////
    // countdown_de.php -- easy to modify countdown script						//
    // Copyright (C) 2004, Juergen Boese - www. jurbo.de						//
    // any comments are welcome: [email protected]								//
    //																			//
    // This software is provided 'as-is', without any expressed or implied		//
    // warranty.  In no event can the author be held liable for any damages		//
    // arising from the use of this software.									//
    //																			//
    // Permission is granted to anyone to use this software freely.				//
    //////////////////////////////////////////////////////////////////////////////


	//set a future date
	$hour = 15;   // 0 ... 24
	$minute = 7;  // 0 ... 60
	$second = 5;  // 0 ... 60
	$month = 6;   // 1 ... 12
	$day = 8;     // 1 ... 28/29/30/31
	$year = 2005; // four digits

	// time in seconds between now and then
	$secdiff = mktime($hour,$minute,$second,$month,$day,$year) - time();
	

	$a = floor ($secdiff/86400); // number of days
	$b = floor ($secdiff%86400/3600); // + number of hours
	$c = floor ($secdiff%86400%3600/60); // + number of minutes
	$d = floor ($secdiff%86400%3600%60); // + number of seconds

	// define extra text
	$text1 = " Still "; $text2 = " days "; $text3 = " hours "; 
	$text4 = " minutes "; $text5 = " and "; $text6 = " seconds "; $text7 = " to go! ";

	//  if the  date you are counting down to is more then x days down the road  
	//  you may not want hours($b), minutes($c) and seconds($d) to be displayed 
	//  to activate this feature, remove '#' at the beginning of the next line
	#   if ($secdiff > 864000) $b = " " . $c = " " . $d = " ";  // (864000 seconds = 10 days)

	// change displayed text and numbers to get the grammar right 
	// and avoid to display "0" days, hours etc.
	if ($a  < 2) $text2 = " day ";
	if ($a < 1) $a = " " . $text2 = " ";
	if ($b  < 2) $text3 = " hour ";
	if ($b < 1) $b = " " . $text3 = " "; 
	if ($c < 2) $text4 = " minute ";
	if ($c < 1) $c = " " . $text4 = " ";
	if ($d < 2) $text6 = " second ";
	if ($d < 1) $d = " " . $text6 = " ";
	if ($d  == 0) $text5 = " ";

	// the countdown message
	if ($secdiff > 0) echo $text1 . $a . $text2 . $b . $text3 . $c . $text4 . $text5 . $d . $text6 . $text7;

	//after countdown is up this message will be displayed
	else echo "The event we counted down to already has occured. ";

?>