[SOLVED] Another Time Question
Posted: Fri Nov 07, 2003 7:03 pm
I have another time question.
I am grabbing the current time when someone hits the page. I want to the round that time up to the next quarter of an hour. So if you hit the page at 4:25 then it is rounded to 4:30 .. 4:31 rounds to 4:45 and so on.
I checked the round and ceil function but they don't look like they would work.
I guess I could always use logic to break it down... Something like
But I was hoping there was an easier way. Does anyone have any ideas?
I am grabbing the current time when someone hits the page. I want to the round that time up to the next quarter of an hour. So if you hit the page at 4:25 then it is rounded to 4:30 .. 4:31 rounds to 4:45 and so on.
I checked the round and ceil function but they don't look like they would work.
I guess I could always use logic to break it down... Something like
Code: Select all
<?php
$minutes = date ("i");
$minutes=($minutes >= 1 && $minutes <= 14)? 15:$minutes;
$minutes=($minutes >= 16 && $minutes <= 29)? 30:$minutes;
$minutes=($minutes >= 31 && $minutes <= 44)? 45:$minutes;
$minutes=($minutes >= 46 && $minutes <= 59)? 00:$minutes;
echo $minutes;
?>