3v4l.org

run code in 300+ PHP versions simultaneously
<?php $startDate = '2001-04-20'; $endDate = '2015-11-29'; $diff = (new DateTime($startDate))->diff(new DateTime($endDate)); $lookup = [ 'y' => 'Year', 'm' => 'Month', 'd' => 'Day', ]; $elements = []; foreach ($lookup as $property => $word) { if ($diff->$property) { $elements[] = "{$diff->$property} $word" . ($diff->$property !== 1 ? 's' : ''); } } echo implode(' : ', $elements);
Output for git.master, git.master_jit, rfc.property-hooks
14 Years : 7 Months : 9 Days

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