Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP Time: get next minute/hour what's divisible by five

Tags:

php

time

I need a code what detect the current time and give me the following time what is divisible by five.

For example: It's: 06 03, 2017 21:22:23 , give me 06 03, 2017 21:25:00 in php. I have no any idea to starting. Is there any code or solution to do this?

like image 359
user3034899 Avatar asked Dec 08 '25 08:12

user3034899


1 Answers

$now = time();
// Add five minutes in seconds, round it down to the nearest five:
$next = ceil($now/300)*300; 
echo date('H:i', $next);
like image 129
Grant Avatar answered Dec 09 '25 22:12

Grant



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!