> I'm getting close to what I want...I currently have this code which loops 
> through all of the next 24 hours:
> 
> <SELECT NAME="futhour">
> <?
> for($i = 0; $i <= 24; $i++):
>          $futhour = strtotime("+$i hour");
>          echo '<OPTION VALUE="'. date('H',$futhour) .'">'. date('g 
> a',$futhour).'</OPTION>';
> endfor;
> ?>
> </SELECT>
> 
> is there a way to include the minutes of the hour in the above code, BUT 
> have the minutes rounded to the nearest 1/2 hour?
> 
> e.g.:
> 12:00
> 12:30
> 1:00
> 1:30

This works. I'm sure there are other ways:

<SELECT NAME="futhour">
<?
$now = time();
$offset = 60-date('i',$now);

for($i = 0; $i <= 1440; $i+=30):
         $futhour = mktime(date('H',$now),
                           date('i',$now)+$i+$offset,
                           date('s',$now),
                           date('m',$now),
                           date('d',$now),
                           date('Y',$now));                          
         echo '<OPTION VALUE="'. date('H:i',$futhour) .'">'. date('g:i 
a',$futhour).'</OPTION>';
endfor;
?>
</SELECT>

---John Holmes...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to