3v4l.org

run code in 300+ PHP versions simultaneously
<?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; }

preferences:
77.44 ms | 402 KiB | 5 Q