3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getDiffInMinutes($startTime, $endTime) { $diff = $startTime->diff($endTime); return round(1440 * $diff->d + 60 * $diff->h + $diff->i + 1/60 * $diff->s); } function getMinutesPerDay($startTime, $endTime) { $output = []; $startDate = $startTime->setTime(0, 0, 0); $endDate = $endTime->setTime(23, 59, 59); $oneDay = new DateInterval('P1D'); $period = new DatePeriod($startDate, $oneDay, $endDate); foreach ($period as $date) { $start = max($startTime, $date); $end = min($endTime, $date->add($oneDay)); $output[$date->format('Y-m-d')] = getDiffInMinutes($start, $end); } return $output; } $startTime = new DateTimeImmutable("2023-08-05 14:45:05"); $endTime = new DateTimeImmutable("2023-08-09 13:00:14"); print_r(getMinutesPerDay($startTime, $endTime));
Output for git.master, git.master_jit, rfc.property-hooks
Array ( [2023-08-05] => 555 [2023-08-06] => 1440 [2023-08-07] => 1440 [2023-08-08] => 1440 [2023-08-09] => 780 )

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:
97.58 ms | 405 KiB | 5 Q