3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $dates = array('2015-04-06', '2015-04-08'); foreach ($dates as $date) { echo '---' . PHP_EOL; $monday = new DateTime($date); $monday->modify('previous monday'); echo $monday->format('Y-m-d H:i:s') . PHP_EOL; $monday = new DateTime($date); $monday->modify('last monday'); echo $monday->format('Y-m-d H:i:s') . PHP_EOL; $monday = new DateTime($date); $monday->modify('monday'); echo $monday->format('Y-m-d H:i:s') . PHP_EOL; }
based on HFO1W
Output for 5.2.7 - 7.2.0
--- 2015-03-30 00:00:00 2015-03-30 00:00:00 2015-04-06 00:00:00 --- 2015-04-06 00:00:00 2015-04-06 00:00:00 2015-04-13 00:00:00
Output for 5.2.0 - 5.2.6
--- 2015-03-30 00:00:00 2015-03-30 00:00:00 2015-04-13 00:00:00 --- 2015-04-06 00:00:00 2015-04-06 00:00:00 2015-04-13 00:00:00
Output for 5.0.2 - 5.1.6
--- Fatal error: Class 'DateTime' not found in /in/sGaCM on line 9
Process exited with code 255.
Output for 5.0.0 - 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sGaCM on line 7 ---PHP_EOL Fatal error: Class 'DateTime' not found in /in/sGaCM on line 9
Process exited with code 255.
Output for 4.3.10 - 4.4.9
--- Fatal error: Cannot instantiate non-existent class: datetime in /in/sGaCM on line 9
Process exited with code 255.
Output for 4.3.2 - 4.3.9
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sGaCM on line 7 ---PHP_EOL Fatal error: Cannot instantiate non-existent class: datetime in /in/sGaCM on line 9
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/sGaCM on line 7 ---PHP_EOL Fatal error: Cannot instantiate non-existent class: datetime in /in/sGaCM on line 9