3v4l.org

run code in 300+ PHP versions simultaneously
<?php $time1 = '1504802148'; // Unix timeStamp $timeDiff = ceil((time() - $time1)); echo secondsToTime($timeDiff); function secondsToTime($seconds) { $dtF = new \DateTime('@0'); $dtT = new \DateTime("@$seconds"); $makeTime = $dtF->diff($dtT)->format('%ad,%hh,%im,%ss'); $data = explode(",", $makeTime); $array = array('0d', '0h', '0m'); $time = array_diff($data, $array); return implode("", $time); }
Output for 5.6.38, 7.0.0 - 7.0.33, 7.1.0 - 7.1.25, 7.2.0 - 7.2.13, 7.3.0
1m10s

preferences:
62.64 ms | 402 KiB | 81 Q