Jump to content


Photo

time and percentages


  • Please log in to reply
1 reply to this topic

#1 dragongamer

dragongamer
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 01 September 2006 - 08:44 AM

ima trying to create a way of dispalying a percantage of how long some thing has ran for, we have the time its starts at and how long its on for in minutes, when i do try to use it it outputs  54, also i need to find a way of making it to show a percentage, by wotking out how many mintues has been on so far, then with the total time of it.

for($i = 0; $i < 6; $i++){
$string = str_replace('new wbl_pr( "', ' ', $WeatherFields[0][$i]);
$string = ereg_replace('["]', '', $string);
$pieces = explode(",", $string);
echo $pieces[0]." ".$pieces[3]." ".$pieces[2]."mins<br>"; 

$stime = explode(" ", $pieces[1]);// trying to get the start time

$finish=$stime[1]+$pieces[2];// start time plus how long the programe is in minutes
echo $finish;
}

http://webzine.drago...les.php?name=TV
has the the information on it.

thanks  ;)

#2 Stuie_b

Stuie_b
  • Members
  • PipPipPip
  • Advanced Member
  • 74 posts
  • LocationNewcastle, UK

Posted 03 September 2006 - 01:39 PM

if you have the length of time it's ran for at a certain point, and the total time it would run for, you could do it like this

$percent =  round($current_time / $total_time * 100,0);
echo $percent;

that should give you a percentage based

hope it helps

Stuie
It's all in the manual :D




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users