3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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( 'y' => 'year', 'm' => 'month', 'w' => 'week', 'd' => 'day', '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'; } $comments_time=2014-04-11 05:07:52 echo time_elapsed_string(date('Y-m-d', strtotime($comments_time)));
Output for 5.4.0 - 5.4.27
Parse error: syntax error, unexpected '05' (T_LNUMBER) in /in/DtVDp on line 31
Process exited with code 255.
Output for 5.1.0 - 5.3.28
Parse error: syntax error, unexpected T_LNUMBER in /in/DtVDp on line 31
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_LNUMBER in /in/DtVDp on line 31
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '&', expecting T_VARIABLE or '$' in /in/DtVDp on line 20
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected '&', expecting T_VARIABLE or '$' in /in/DtVDp on line 20
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_VARIABLE' or `'$'' in /in/DtVDp on line 20
Process exited with code 255.