There's nothing built in that allows you to retrieve 'increments' however you can calculate it with minimal code.
(内置没有任何东西可以让您检索“增量”,但是您可以用最少的代码进行计算。)
The use of modulo here allows you to figure out how far past the most recent 5 minute mark is. (在这里使用模数,可以算出最近5分钟标记的距离。)
It will never be greater than 5 minutes (300 seconds) and can always be subtracted safely to take you back to the time you want. (它永远不会超过5分钟(300秒),并且始终可以安全地减去它,以使您回到想要的时间。)
$now = time();
echo $now . PHP_EOL;
$five_minutes = 60*5; // 300
$offset = $now % $five_minutes;
$five_block = $now - $offset;
echo date('Y-m-d H:i:s', $five_block);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…