3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $interval_in_seconds = 12 * 86400; $checkin_in_seconds = floor(1413926734544 / 1000); $next_checkin = $checkin_in_seconds + $interval_in_seconds; $until_next = $next_checkin - time(); if($until_next > 0) { $days = floor($until_next / 86400); function secondsToTime($seconds) { // Only here for var_dump testing: global $settings, $interval_in_seconds, $until_next, $next_checkin; $dtF = new DateTime("@0"); $dtT = new DateTime("@$seconds"); var_dump($until_next); $return = $dtF->diff($dtT)->format('%h hours, %i minutes and %s seconds'); var_dump($until_next); return $return; } $countdown = $days . ' days, ' . secondsToTime($until_next); } echo $countdown;
based on RHb7d
Output for 5.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
float(1030519) float(1030519) 11 days, 22 hours, 15 minutes and 19 seconds
Output for 5.2.0 - 5.2.17
float(1030519) Fatal error: Call to undefined method DateTime::diff() in /in/8pBXR on line 19
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/8pBXR on line 15
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/8pBXR on line 19
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_OBJECT_OPERATOR in /in/8pBXR on line 19
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/8pBXR on line 19
Process exited with code 255.