3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $weekModifier = 0; $date = new DateTime(); if($date->format('N') !== 1) { $date->sub(new DateInterval('P'. $date->format('N') . 'D')); } $interval = new DateInterval('P'.abs($weekModifier).'W'); if($weekModifier > 0) { $date->add($interval); } else { $date->sub($interval); } for($i = 1; $i <= 7; $i++) { echo $date->add(new DateInterval('P1D'))->format('l Y-m-d') . "<br>\n"; } ?>
Output for 5.4.33, 5.5.17, 5.5.37 - 5.5.38, 5.6.23 - 5.6.27, 5.6.29 - 5.6.30, hhvm-3.10.1 - 3.22.0, 7.0.8 - 7.0.13, 7.0.15 - 7.0.19, 7.0.21 - 7.0.31, 7.1.1 - 7.1.4, 7.1.8 - 7.1.9, 7.1.11 - 7.1.19, 7.1.21, 7.2.1 - 7.2.5, 7.2.7 - 7.2.9
Monday 2018-08-20<br> Tuesday 2018-08-21<br> Wednesday 2018-08-22<br> Thursday 2018-08-23<br> Friday 2018-08-24<br> Saturday 2018-08-25<br> Sunday 2018-08-26<br>
Output for 5.6.28, 7.0.14, 7.0.20, 7.1.0, 7.1.5 - 7.1.7, 7.1.10, 7.1.20, 7.2.0, 7.2.6
Monday 2016-04-18<br> Tuesday 2016-04-19<br> Wednesday 2016-04-20<br> Thursday 2016-04-21<br> Friday 2016-04-22<br> Saturday 2016-04-23<br> Sunday 2016-04-24<br>
Output for 5.3.0 - 5.4.32, 5.4.34 - 5.5.16, 5.5.18 - 5.5.36, 5.6.0 - 5.6.22, 7.0.0 - 7.0.7
Monday 2014-04-21<br> Tuesday 2014-04-22<br> Wednesday 2014-04-23<br> Thursday 2014-04-24<br> Friday 2014-04-25<br> Saturday 2014-04-26<br> Sunday 2014-04-27<br>
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined method DateTime::sub() in /in/tCiN1 on line 8
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/tCiN1 on line 5
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_OBJECT_OPERATOR, expecting ',' or ';' in /in/tCiN1 on line 20
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_OBJECT_OPERATOR, expecting ',' or ';' in /in/tCiN1 on line 20
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `','' or `';'' in /in/tCiN1 on line 20
Process exited with code 255.