3v4l.org

run code in 300+ PHP versions simultaneously
<?php function roundTime(int $seconds, int $intervalInMinutes, bool $roundDown) { $functionName = $roundDown ? 'floor' : 'ceil'; $intervalSeconds = $intervalInMinutes * 60; $roundedSeconds = $functionName($seconds / $intervalSeconds) * $intervalSeconds; return date('H:i', $roundedSeconds) . "\n"; } echo roundTime(3600* 14 + 14 * 60, 15, FALSE); echo roundTime(3600* 14 + 15 * 60, 15, FALSE); echo roundTime(3600* 14 + 16 * 60, 15, FALSE); echo "\n"; echo roundTime(3600* 14 + 14 * 60, 15, TRUE); echo roundTime(3600* 14 + 15 * 60, 15, TRUE); echo roundTime(3600* 14 + 16 * 60, 15, TRUE); echo "\n"; echo roundTime(3600* 14 + 14 * 60, 30, FALSE); echo roundTime(3600* 14 + 31 * 60, 30, FALSE); echo roundTime(3600* 14 + 46 * 60, 30, FALSE); echo "\n"; echo roundTime(3600* 14 + 14 * 60, 30, TRUE); echo roundTime(3600* 14 + 31 * 60, 30, TRUE); echo roundTime(3600* 14 + 46 * 60, 30, TRUE); echo "\n";
Output for git.master_jit, git.master, rfc.property-hooks
15:15 15:15 15:30 15:00 15:15 15:15 15:30 16:00 16:00 15:00 15:30 15:30

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
51.16 ms | 997 KiB | 4 Q