I have a PHP page to show a select list of time in half an hour interval. For now I selected it manually <option value="oneThirty">1:30AM</option> <option value="two">2AM</option> ... Is there way I can do it using loop in PHP with half hour interval and how? Thanks
maybe something like this: <? for($hour=0;$hour<24;$hour++){ if($hour<12){ $ampm = "AM"; } else { $ampm = "PM"; } $selTime .= "<option value=\"".sprintf("%02d",$hour).":00$ampm\">".sprintf("%02d",$hour).":00$ampm</option>"; $selTime .= "<option value=\"".sprintf("%02d",$hour).":30$ampm\">".sprintf("%02d",$hour).":30$ampm</option>"; } ?> <select> <?=$selTime?> </select> PHP: