Jump to content


Photo

Minutes Remaining


  • Please log in to reply
1 reply to this topic

#1 ego0

ego0
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 06 September 2006 - 07:32 PM

I Have two dates both in the unix? format

Countdown to date September, 18, 2006, 4:17:00 1158567428

and

date now September 6, 2006, 3:28:51 1157570931

I having trouble making a countdown to the minutes and seconds left from the time the script is run to the countdown date. :( Not a live countdown.

#2 obsidian

obsidian
  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 06 September 2006 - 07:46 PM

i'm not sure i understand the format you're talking of. are the "1158567428" and "1157570931" representative of the times you have? if so, then just try something like this:
<?php
function getRemainder($time) {
  $now = time();
  $diff = abs($time - $now);
  $res = array(
    'mins' => floor($diff / 3600),
    'secs' => ($diff % 3600)
  );
  return $res;
}

$time = 1158567428; // countdown to
$rem = getRemainder($time);
echo "There are $rem[mins] minutes and $rem[secs] seconds left!";
?>

hope this helps
You can't win, you can't lose, you can't break even... you can't even get out of the game.

<?php
while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users