3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function diff($diff) { if (5184000 < $diff) { // = 24*60*60*60 = 60 days return 'week'; } elseif (86400 < $diff) { // = 24*60*60 = 24 hours return 'day'; } elseif (3600 < $diff) { // = 60*60 = 60 minutes return 'hour'; } elseif (120 < $diff) { // = 2*60 = 2 minutes return 'minute'; } else { return 'second'; } } echo diff(1393887600-1393844400);
Output for 4.3.0 - 5.6.25, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
hour