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; $string = array( 'h' => 'hour', 'i' => 'minute', 's' => 'second', ); foreach ($string as $k => &$v) { if ($diff->$k) { $v = $diff->$k . ' ' . $v . ($diff->$k > 1 ? 's' : ''); } else { unset($string[$k]); } } if (!$full) $string = array_slice($string, 0, 1); return $string ? implode(', ', $string) . ' ago' : 'just now'; } $date = date_parse_from_format('Y-d-m H:i:s', '2014-02-05 5:22:35'); $unixTimestamp = mktime( $date['hour'], $date['minute'], $date['second'], $date['month'], $date['day'], $date['year'] ); echo time_elapsed_string(@$unixTimestamp, true);
Output for git.master, git.master_jit
Fatal error: Uncaught Exception: Failed to parse time string (1399000955) at position 8 (5): Unexpected character in /in/64aQu:5 Stack trace: #0 /in/64aQu(5): DateTime->__construct('1399000955') #1 /in/64aQu(34): time_elapsed_string(1399000955, true) #2 {main} thrown in /in/64aQu on line 5
Process exited with code 255.
Output for rfc.property-hooks
Fatal error: Uncaught DateMalformedStringException: Failed to parse time string (1399000955) at position 8 (5): Unexpected character in /in/64aQu:5 Stack trace: #0 /in/64aQu(5): DateTime->__construct('1399000955') #1 /in/64aQu(34): time_elapsed_string(1399000955, true) #2 {main} thrown in /in/64aQu on line 5
Process exited with code 255.

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:
40.17 ms | 401 KiB | 8 Q