3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $dateString = date('Y-m-d'); $dateArray = explode('-',$dateString); $month = intval($dateArray[1]) + 1; $day = intval($dateArray[2]); if ($day > 28){ $day = 1; $month += 1; } $newdate = $dateArray[0].'-'.$month.'-'.$day; $date = new DateTime('$newdate'); echo $date->format('Y-m-d'); ?>
Output for 7.0.0 - 7.2.0
Fatal error: Uncaught Exception: DateTime::__construct(): Failed to parse time string ($newdate) at position 0 ($): Unexpected character in /in/eWTfq:12 Stack trace: #0 /in/eWTfq(12): DateTime->__construct('$newdate') #1 {main} thrown in /in/eWTfq on line 12
Process exited with code 255.
Output for 5.5.0 - 5.6.28
Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string ($newdate) at position 0 ($): Unexpected character' in /in/eWTfq:12 Stack trace: #0 /in/eWTfq(12): DateTime->__construct('$newdate') #1 {main} thrown in /in/eWTfq on line 12
Process exited with code 255.