Date Difference in day:hours:minutes PHP time remaining from now till future date

Hello, i am a coldfusin prgrammer and got stuck with running a PHP auction....i need to show time remaining in hours:minutes:seconds from now til future date

eg,
from current server time  to April 31, 2006 @ 8:00 pm.  

can someone help me.  

thanks
dpedersenAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BogoJokerCommented:
BogoJokerCommented:
Here is the code from that tutorial:

<?php
// Change this to the day in the future
$day = 8;
// Change this to the month in the future
$month = 31;
// Change this to the year in the future
$year = 2006;
// $days is the number of days between now and the date in the future
$days = (int)((mktime (0,0,0,$month,$day,$year) - time(void))/86400);
echo "There are $days days until $day/$month/$year";
?>



Joe P

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BogoJokerCommented:
This work for you?

Joe P
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

dpedersenAuthor Commented:
Joe,
it shows the days remaining fine, but i need to see hours:minutes:seconds.  can you formated it to show that.  
BogoJokerCommented:
The 0,0,0 in mktime stands for hours, minutes, seconds
<?php
// Change this to the day in the future
$day = 8;
// Change this to the month in the future
$month = 31;
// Change this to the year in the future
$year = 2006;
// $days is the number of days between now and the date in the future
$days = (int)((mktime (20,0,0,$month,$day,$year) - time(void))/86400);
echo "There are $days days until $day/$month/$year";
?>

Try that

Joe P
dpedersenAuthor Commented:
ive made these changes to the code
<?php
// Change this to the day in the future
$day = 31;
// Change this to the month in the future
$month = 4;
// Change this to the year in the future
$year = 2006;
$hour = 20;
$minute = 00;
$second = 00;
// $days is the number of days between now and the date in the future
$days = (int)((mktime ($hour,$minute,$second,$month,$day,$year) - time(void))/3600);
echo "There are $days minutes until $month/$day/$year @ $hour:$minute:$second";
?>

this outputs remaining minutes however, i want the output formated to appear like this

30 days, 12 hours, 36 minutes , 4 seconds remaining

can you do that
dpedersenAuthor Commented:
i answered my own question
i found this on the web

<?php
// countdown function
// parameters: (year, month, day, hour, minute)
countdown(2006,4,31,20,00);

//--------------------------
// author: Louai Munajim
// website: www.elouai.com
//
// Note:
// Unix timestamp limitations
// Date range is from
// the year 1970 to 2038
//--------------------------
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);
  $seconds_left = floor(($difference - $days_left*60*60*24 - $hours_left*60*60 - $minutes_left*60));
 
  // OUTPUT
echo "There are $days_left Days, $hours_left Hours and $minutes_left Minutes, $seconds_left seconds until $month/$day/$year @ $hour:$minute:$second";


}
?>
dpedersenAuthor Commented:
joe p im giving you half points for keeping me focused and interested. and getting me looking in the right track
thanks
BogoJokerCommented:
Sure

Joe P
BogoJokerCommented:
http://www.experts-exchange.com/help.jsp#hi75
I would have liked the chance to earn at least a B grade.  Any clarification on my part, further instruction that would have warrented at least a B grade?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.