开发者

Rounding time to nearest quarter, atleast 30 minutes in time

Bah, I've been fiddling on how to do this. I need a function that returns <hour>:<minutes> that is rounded to a quarter, but need to be atleast 30 minutes in future time.

Anyone got a go开发者_运维问答od idea and how to do this?


  1. Add 30 minutes.

  2. Extract date + hour on the one hand side, minutes on the other.

  3. Divide minutes by 15, ceil the result, multiply by 15.

  4. Build new date using date + hour and add the new minutes.


$current = date("Hi");
$ceilUp = ceil($current / 15);
$timeNeeded = $ceilUp + 30;

something like that? (I see it's not exactly what you need.. but this is a start).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜