3v4l.org

run code in 500+ 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', ]; $output = 'mere seconds'; foreach ($lookup as $property => $word) { if ($amt = $diff->$property) { if ($property === 'd' && $diff->$property >= 7) { $amt = intdiv($diff->$property, 7); $word = 'week'; } $output = "$amt $word" . ($amt !== 1 ? 's' : ''); break; } } echo "for $output";
Output for git.master_jit, git.master
for 4 years

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:
49.44 ms | 699 KiB | 4 Q