3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $format = 'Y-m-d H:i:s'; $days_left = 7; $dayStart = new DateTime("midnight $daysAgo days ago"); $dayEnd = new DateTime('midnight '.($daysAgo+1).' days ago'); echo $dayStart->format($format); echo $dayEnd->format($format);
based on s4Z19
Output for 7.0.0 - 7.2.0
Notice: Undefined variable: daysAgo in /in/BGIF6 on line 5 Fatal error: Uncaught Exception: DateTime::__construct(): Failed to parse time string (midnight days ago) at position 10 (d): The timezone could not be found in the database in /in/BGIF6:5 Stack trace: #0 /in/BGIF6(5): DateTime->__construct('midnight days ...') #1 {main} thrown in /in/BGIF6 on line 5
Process exited with code 255.
Output for 5.3.19 - 5.6.28
Notice: Undefined variable: daysAgo in /in/BGIF6 on line 5 Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string (midnight days ago) at position 10 (d): The timezone could not be found in the database' in /in/BGIF6:5 Stack trace: #0 /in/BGIF6(5): DateTime->__construct('midnight days ...') #1 {main} thrown in /in/BGIF6 on line 5
Process exited with code 255.