[SOLVED] Countdown Script
Posted: Fri Apr 03, 2009 10:59 pm
Hi Everyone,
I need to add a countdown to date script on my site.
I found the following PHP script, but I can't seem to get it to work on the site. I put it in as a UDT. When I preview my page with it on there, from where I added the tag and on down - it is blank. I figure that it is probably some further customization I need to do to it so that it can work on the CMSMS site, I am just not sure what to do.
Here it is:
[php]
function countdown($year, $month, $day, $hour, $minute)
{
// make a unix timestamp for the given date
$the_countdown_date = mktime($hour, $minute, 0, $month, $day, $year, -1);
// get current unix timestamp
$today = time();
$difference = $the_countdown_date - $today;
if ($difference < 0) $difference = 0;
$days_left = floor($difference/60/60/24);
$hours_left = floor(($difference - $days_left*60*60*24)/60/60);
$minutes_left = floor(($difference - $days_left*60*60*24 - $hours_left*60*60)/60);
// OUTPUT
echo "Countdown ".$days_left." days ".$hours_left." hours ".$minutes_left." minutes left";
}
[/php]
Any suggestions?
I need to add a countdown to date script on my site.
I found the following PHP script, but I can't seem to get it to work on the site. I put it in as a UDT. When I preview my page with it on there, from where I added the tag and on down - it is blank. I figure that it is probably some further customization I need to do to it so that it can work on the CMSMS site, I am just not sure what to do.
Here it is:
[php]
function countdown($year, $month, $day, $hour, $minute)
{
// make a unix timestamp for the given date
$the_countdown_date = mktime($hour, $minute, 0, $month, $day, $year, -1);
// get current unix timestamp
$today = time();
$difference = $the_countdown_date - $today;
if ($difference < 0) $difference = 0;
$days_left = floor($difference/60/60/24);
$hours_left = floor(($difference - $days_left*60*60*24)/60/60);
$minutes_left = floor(($difference - $days_left*60*60*24 - $hours_left*60*60)/60);
// OUTPUT
echo "Countdown ".$days_left." days ".$hours_left." hours ".$minutes_left." minutes left";
}
[/php]
Any suggestions?