3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dt = new StdClass; $dt->now = new DateTime(); $occurredOn = new DateTime(); $dt->lastUpdated = $occurredOn; $dt->remainingHours = $occurredOn; $dt->interval = $dt->now->diff($dt->lastUpdated); $dt->remainingHours->add(new DateInterval("PT4H")); $dt->remainingHours = $dt->remainingHours->diff($dt->now); $dt->remainingHours = $this->timeService->timeRemainingInFourHours($dt->remainingHours); $dt->title = $this->timeService->formatDateInterval($dt->interval); function timeRemainingInFourHours(DateInterval $interval) { $hours = ""; $minutes = ""; if ($interval->h) { $hours = $interval->format("%h") . " hours"; } if ($interval->i) { $minutes = $interval->format("%i") . " minutes"; } return $hours . $minutes . ' remaining'; } function formatDateInterval(DateInterval $interval) { $result = ""; // ternary? if ($interval->y) { $result .= $interval->format("%y years "); } if ($interval->m) { $result .= $interval->format("%m months "); } if ($interval->d) { $result .= $interval->format("%d days "); } if ($interval->h) { $result .= $interval->format("%h hours "); } if ($interval->i) { $result .= $interval->format("%i minutes "); } if ($interval->s) { $result .= $interval->format("%s seconds "); } else { $result .= "hot off the press"; } return $result; } var_dump($dt);
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Using $this when not in object context in /in/0vV7H:16 Stack trace: #0 {main} thrown in /in/0vV7H on line 16
Process exited with code 255.

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:
43.85 ms | 401 KiB | 8 Q