I am currently using the following PHP code generate a Select Box with different times:
<?
for ($x = 28; $x < 81; $x++) {
if ($x == 48) {
print "<option selected='selected' value='" . date("H:i:s", mktime(0, $x * 15, 0, 0, 0)) . "'>" . date("g:i a", mktime(0, $x * 15, 0, 0, 0)) . "</option>";
}
else {
print "<option value='" . date("H:i:s", mktime(0, $x * 15, 0, 0, 0)) . "'>" . date("g:i a", mktime(0, $x * 15, 0, 0, 0)) . "</option>";
}
}
?>
All the times are at 15 minute intervals: 12:00:00 12:15:00 12:30:00 12:45:00 13:00:00 //etc...
What I'd like to know is: How can I given the current time, make the closest time the "selected" time.
For example, if the current PHP time is: 12:32:14, I'd like it to select "12:45 pm."
Any ideas on how to do this?