[thelist] PHP time based for/next loop

fstorr fffrancis at fstorr.demon.co.uk
Sun Jan 18 09:34:02 CST 2004


Michael Pemberton wrote:

> PHP has the "floor" function.  This will allow you to round down to the 
> nearest whole number.  This should do what your looking for.

+++++++++

Hi Michael

I remember lookin at the floor function too many hours ago and not 
getting it to work. Well, it's fixed and without looping 60 times.  It 
seems to work as planned, so thanks for the reminder:

$minutes = date("i");
$act_mins = floor($minutes / 15);

echo "<select name=\"minutes\">\n";

for ($now_minutes = 0; $now_minutes <=3; ++$now_minutes)

{
  $quarter = $now_minutes *15;

   echo "<option value=\"" . ($quarter < 15 ? "0$quarter" : "$quarter") 
. "\"";
	
   if ($act_mins == $now_minutes)
	
   {
     echo " selected=\"selected\"";
   }

echo ">" . ($quarter < 15 ? "0$quarter" : "$quarter") . "</option>\n";

}

echo "</select>\n";



More information about the thelist mailing list