3v4l.org

run code in 300+ PHP versions simultaneously
<?php function time_elapsed_string($datetime, $full = false) { $now = new DateTime; $ago = new DateTime($datetime); $diff = $now->diff($ago); $diff->w = floor($diff->d / 7); $diff->d -= $diff->w * 7; $periods = array( 'y' => ['jaar', 'jaren'], 'm' => ['maand', 'maanden'], 'w' => ['week', 'weken'], 'd' => ['dag', 'dagen'], 'h' => ['uur', 'uren'], 'i' => ['minuut', 'minuten'], 's' => ['seconde', 'seconden'] ); $parts = array(); foreach ($periods as $k => &$v) { if ($diff->$k) { $parts[] = $diff->$k . ' ' . $v[$diff->$k > 1]; } } if (!$full) $parts = array_slice($parts, 0, 1); return $parts ? implode(', ', $parts) . ' ago' : 'just now'; } echo time_elapsed_string('2020-03-21 00:30:16') . PHP_EOL; echo time_elapsed_string('2020-03-21 00:30:16', true) . PHP_EOL;
Output for git.master, git.master_jit
Deprecated: Creation of dynamic property DateInterval::$w is deprecated in /in/WOmOR on line 8 2 maanden ago Deprecated: Creation of dynamic property DateInterval::$w is deprecated in /in/WOmOR on line 8 2 maanden, 1 week, 3 dagen, 14 uren, 6 minuten, 55 seconden ago
Output for rfc.property-hooks
Deprecated: Creation of dynamic property DateInterval::$w is deprecated in /in/WOmOR on line 8 3 jaren ago Deprecated: Creation of dynamic property DateInterval::$w is deprecated in /in/WOmOR on line 8 3 jaren, 3 maanden, 3 weken, 6 dagen, 14 uren, 11 minuten, 32 seconden ago

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:
26.41 ms | 407 KiB | 5 Q