3v4l.org

run code in 300+ PHP versions simultaneously
<?php $date = '10.11.2021 14:00'; $diff = (new DateTime($date))->diff(new DateTime()); $lookup = [ 'y' => 'year', 'm' => 'month', 'd' => 'day', 'h' => 'hour', 'i' => 'minute', ]; foreach ($lookup as $property => $word) { if ($diff->$property) { if ($property === 'd' && $diff->$property >= 7) { $diff->w = (int)($diff->$property / 7); $property = 'w'; $word = 'week'; } $output = "for {$diff->$property} $word" . ($diff->$property !== 1 ? 's' : ''); break; } } echo $output ?? 'for mere seconds';
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Creation of dynamic property DateInterval::$w is deprecated in /in/InN7V on line 17 for 3 weeks

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