3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $timestamps = array( strtotime("now"), strtotime("-3 seconds"), strtotime("-30 minutes"), strtotime("-60 minute"), strtotime("-90 minutes"), strtotime("-1550 minutes"), strtotime("-889385 seconds"), ); $dateTimeFile = new DateTime(); foreach ($timestamps as $timestamp) { $dateTimeFile->setTimestamp($timestamp); $interval = (new DateTime)->diff($dateTimeFile); echo sprintf( "%s%s%s%s", $interval->d > 0 ? $interval->d . "d " : "", $interval->h > 0 ? $interval->h . "h " : "", $interval->i > 0 ? $interval->i . "m " : "", $interval->s > 0 ? $interval->s . "s " : "" ); echo PHP_EOL; }
Output for 5.4.10 - 7.1.0, 7.1.6 - 7.2.0
3s 30m 1h 1h 30m 1d 1h 50m 10d 7h 3m 5s
Output for 7.1.5
1s 2s 29m 59s 59m 59s 1h 29m 59s 1d 1h 49m 59s 10d 7h 3m 4s
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/LGOer on line 16
Process exited with code 255.