Countdown To 2011
Started on the old forum in August 2010 · view the original in the archive · old links redirect here
function countdown()
{
//A
$today = time();
//B
$event = mktime(0,0,0,12,25,date("Y"));
//C
$apart = $event - $today;
//D
if ($apart >= -86400)
{
$myevent = $event;
}
//E
else
{
$myevent = mktime(0,0,0,12,25,date("Y")+1);
}
//F
$countdown = round(($myevent - $today)/86400);
//G
if ($countdown > 1)
{
echo "$countdown days until Christmas";
}
//H
elseif (($myevent-$today) <= 0 && ($myevent-$today) >= -86400)
{
echo "Today is Christmas!";
}
//I
else
{
echo "$countdown day until Christmas";
}
}
echo countdown();
Visit: Chat4u.mobi - The New Lay Of being a site of your dreams! Visit: WapMasterz Coming Back Soon!
SCRIPTS FOR SALE BY SUBZERO Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders. FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others... _______…
function countdown() { //A $today = time(); //B $event = mktime(0,0,0,12,25,date("Y")); //C $apart = $event - $today; //D if ($apart >= -86400) { $myevent = $event; } //E else { $myevent = mktime(0,0,0,12,25,date("Y")+1); } //F $countdown = round(($myevent - $today)/86400); //G if ($countdown > 1) { echo "$countdown days until Christmas"; } //H elseif (($myevent-$today) <= 0 && ($myevent-$today) >= -86400) { echo "Today is Christmas!"; } //I else { echo "$countdown day until Christmas"; } }echo countdown();
Wher does the echo countdown bit?
<?PHP
date_default_timezone_set('Europe/London');
if ($date->format('n')==12 && $date->format('d')>24){
$thisyear = $date->format('Y') + 1;}
else{ $thisyear = $date->format('Y'); }
$time = mktime(0, 0, 0, 12, 25, $thisyear, 23) - time();
$days = floor($time/86400);
$hours = floor(($time-($days*86400))/3600);
$mins = floor (($time-($days*86400)-($hours*3600))/60);
$secs = floor ($time-($days*86400)-($hours*3600)-($mins*60));
$tsecs = $time;
$tmins = round($time/3600*60);
$thours = round($time/3600);
/*
************************************************
HOW TO DISPLAY THE NUMBER OF DAYS LEFT
otherwise you would have to say something
like "Only 1 day(s) left". This looks better!
************************************************
*/
if ($days == 1){
$daysremain = 'day';}
if ($days == 0){
$daysremain = '';}
else{
$daysremain = 'days';}
if ($days == 0){
$days = '';}
/*
************************************************
HOW TO DISPLAY THE NUMBER OF HOURS LEFT
************************************************
*/
if ($hours == 1){
$hoursremain = 'hour';}
if ($hours == 0){
$hoursremain = '';}
else{
$hoursremain = 'hours';}
if ($hours == 0){
$hours = '';}
/*
************************************************
AND NOW FOR THE MINUTES
************************************************
*/
if ($mins == 1){
$minsremain = 'minute';}
if ($mins == 0){
$minsremain = '';}
else{
$minsremain = 'minutes';}
if ($mins == 0){
$mins = '';}
echo '<div><h2>UK Countdown To Christmas '. $thisyear .'</h2>';
echo'It\'s only <b>' . $days . '</b> '. $daysremain .' <b>' . $hours . '</b> '. $hoursremain .' and <b>' . $mins . '</b> '. $minsremain .' until Christmas!<br/>';
echo '<br/>That\'s only <b>' . number_format($tmins) . '</b> minutes<br/>which is about <b>' . number_format($thours) . '</b> hours!<br/></div>';
?>
Just visiting!