3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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());
based on A4Aoo
Output for 7.0.0 - 7.2.0
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.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.