3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function timePassed($time){ $time = time() - $time; echo $time; $tokens = array ( 31536000 => 'year', 2592000 => 'month', 604800 => 'week', 86400 => 'day', 3600 => 'hour', 60 => 'minute', 1 => 'second' ); foreach ($tokens as $unit => $text) { if ($time < $unit) continue; $numberOfUnits = floor($time / $unit); return $numberOfUnits.' '.$text.(($numberOfUnits>1)?'s':''); } } echo timePassed('2014-04-03 19:21:30');
Output for 7.1.0
Notice: A non well formed numeric value encountered in /in/39Cn3 on line 3 139768782844 years
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.0.14
139768782844 years