operator error. I didn't show all the code. Here it is;
$display_time = date("H:i");
// round time to nearest 15 minute interval
$display_timex = explode (":",$display_time) ;
if (($display_timex[1] >= 00) || ($display_timex[1] <= 07)) {
$insert_time = $display_timex[0] . ":00";
} elseif (($display_timex[1] >= 8) && ($display_timex[1] <= 22)) {
$insert_time = $display_timex[0] . ":15";
} elseif (($display_timex[1] >= 23) && ($display_timex[1] <= 37)) {
$insert_time = $display_timex[0] . ":30";
} elseif (($display_timex[1] >= 38) && ($display_timex[1] <= 52)) {
$insert_time = $display_timex[0] . ":45";
} elseif (($display_timex[1] >= 53) && ($display_timex[1] <= 59)) {
$display_timex[0]++;
$insert_time = $display_timex[0] . ":00";
}
The first if statement has a || instead of an &&
My mistake. The correct code that works is;
$display_time = date("H:i");
// round time to nearest 15 minute interval
$display_timex = explode (":",$display_time) ;
if (($display_timex[1] >= 00) && ($display_timex[1] <= 07)) {
$insert_time = $display_timex[0] . ":00";
} elseif (($display_timex[1] >= 8) && ($display_timex[1] <= 22)) {
$insert_time = $display_timex[0] . ":15";
} elseif (($display_timex[1] >= 23) && ($display_timex[1] <= 37)) {
$insert_time = $display_timex[0] . ":30";
} elseif (($display_timex[1] >= 38) && ($display_timex[1] <= 52)) {
$insert_time = $display_timex[0] . ":45";
} elseif (($display_timex[1] >= 53) && ($display_timex[1] <= 59)) {
$display_timex[0]++;
$insert_time = $display_timex[0] . ":00";
}
Thanks for all that replied.
Tom
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php