3v4l.org

run code in 300+ PHP versions simultaneously
<?php $date = \DateInterval::createFromDateString('2 days 5 minutes'); function doSomeMagic(\DateInterval $date) { $interval = 'P' . ($date->y == 0 ? null : $date->y . 'Y') . ($date->m == 0 ? null : $date->m . 'M') . ($date->d == 0 ? null : $date->d . 'D'); $timeInterval = ($date->h == 0 ? null : $date->h . 'H') . ($date->i == 0 ? null : $date->i . 'M') . ($date->s == 0 ? null : $date->y . 'S'); return $interval . ((!empty($timeInterval)) ? 'T' . $timeInterval : null); } $period = doSomeMagic($date); echo $period;
Output for git.master, git.master_jit, rfc.property-hooks
P2DT5M

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