3v4l.org

run code in 300+ PHP versions simultaneously
<?php function roundToNextHour($dateString) { $date = new DateTime( $dateString ); $minutes = $date->format('i'); if($minutes > 0){ $date->modify("+1 hour"); $date->modify('-'.$minutes.' minutes'); } return $date; } echo roundToNextHour(time());
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.6
Fatal error: Uncaught Exception: DateTime::__construct(): Failed to parse time string (1445905349) at position 8 (4): Unexpected character in /in/fO7HM:4 Stack trace: #0 /in/fO7HM(4): DateTime->__construct('1445905349') #1 /in/fO7HM(13): roundToNextHour(1445905349) #2 {main} thrown in /in/fO7HM on line 4
Process exited with code 255.
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.37, 5.6.0 - 5.6.28
Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string (1445905349) at position 8 (4): Unexpected character' in /in/fO7HM:4 Stack trace: #0 /in/fO7HM(4): DateTime->__construct('1445905349') #1 /in/fO7HM(13): roundToNextHour(1445905349) #2 {main} thrown in /in/fO7HM on line 4
Process exited with code 255.

preferences:
109.17 ms | 402 KiB | 130 Q