Months, Days, Hours Countdown Script

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   Months, Days, Hours Countdown Script
bxfl
CZ Super Newbie
bxfl has been a member for over 20 year's 20 Year Member
Gender: Female
Website:
Status: Offline
Joined: Mar 22, 2004
0.01 posts per day
Posts: 60
Points: 2,594
AIM Address   
I'm looking for a simple-to-edit countdown script that counts down in months, days, and hours to a date. (Sept 28th 2005, if you want to already edit it for me ^.^)

Thanks so much!



Back to top Reply with quote
#2   re: Months, Days, Hours Countdown Script
Kelly_Hero
PayPal Donation
CZ Revered Member
 Codezwiz Site Donator
Kelly_Hero has been a member for over 20 year's 20 Year Member
usa.gif southcarolina.gif
Occupation: Web Developer
Age: 59
Gender: Female
Website:
Status: Offline
Joined: Aug 20, 2003
0.50 posts per day
Posts: 3765
Points: 351,412
   
Try this:
[ Register or login to view links on this board. ]



Back to top Reply with quote
#3   re: Months, Days, Hours Countdown Script
just-a-number
CZ Newbie
just-a-number has been a member for over 19 year's 19 Year Member
Gender: Male
Status: Offline
Joined: Mar 30, 2005
0.00 posts per day
Posts: 2
Points: 71
   
Javascript for text-generation is implicitly fround upon by search engines, particularly google. In essence, it is a form of 'cloaking', albeit with generally the opposite affect of most cloak operations.

Furthermore, I couldn't find a single *simple* PHP countdown script, so I simply re-created the one i made a few years ago...this one is far more elegant I might add.

[code]<?php
// Copyright: None | All rights relinquished.
// License: Public Domain

function countdown($month, $day, $year, $hr, $min)
{
// NOTE: UNIX time is in seconds from the first year the
// UNIX kernel was compiled: 1/1/1970. As such, vanishingly
// few modern machines can handle UNIX dates in excess of
// 2036, as at this time you will run into various size
// limitations, much like Y2K, only worse :p
$unix_sec = mktime($hr, $min, 0, $month, $day, $year, -1);
$current_sec = time();

$left = abs($unix_sec - $current_sec);

if ($left <= 0)
{
return "0 seconds left.";
}

/* This could be made *far* smaller by use of a recursive algorithm, but what's the point? */
$time['abs_d'] = floor($left / (3600 * 24));
$time['mon'] = floor($time['abs_d'] / 30);
$time['d'] = $time['abs_d'] - ($time['mon'] * 30);
$time['h'] = floor(($left - ($time['abs_d'] * 3600 * 24)) / 3600);
$time['m'] = floor(($left - ($time['abs_d'] * 3600 * 24) - ($time['h'] * 3600)) / 60);

return $time;
}

/* ----- Example ----- */
$count = countdown(9, 28, 2005, 9, 35);

print "<h1>Time remaining: $count[abs_d] days, or $count[mon] months, $count[d] days $count[h] hours $count[m] minutes </h1>\n";

/* ------ Results ------ */
// Time remaining: 182 days, or 6 months, 2 days 0 hours 32 minutes
?>
[/count]



Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum