3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $weekModifier = 2; $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.6.28, 7.0.12 - 7.1.0
Monday 2014-05-26<br> Tuesday 2014-05-27<br> Wednesday 2014-05-28<br> Thursday 2014-05-29<br> Friday 2014-05-30<br> Saturday 2014-05-31<br> Sunday 2014-06-01<br>
Output for 7.0.6
Monday 2016-05-16<br> Tuesday 2016-05-17<br> Wednesday 2016-05-18<br> Thursday 2016-05-19<br> Friday 2016-05-20<br> Saturday 2016-05-21<br> Sunday 2016-05-22<br>
Output for 5.5.30, 5.6.14 - 5.6.15, hhvm-3.10.0, 7.0.5
Monday 2016-04-11<br> Tuesday 2016-04-12<br> Wednesday 2016-04-13<br> Thursday 2016-04-14<br> Friday 2016-04-15<br> Saturday 2016-04-16<br> Sunday 2016-04-17<br>
Output for 5.5.33, hhvm-3.12.0, 7.0.4
Monday 2016-03-21<br> Tuesday 2016-03-22<br> Wednesday 2016-03-23<br> Thursday 2016-03-24<br> Friday 2016-03-25<br> Saturday 2016-03-26<br> Sunday 2016-03-27<br>
Output for 5.5.31 - 5.5.32, 5.6.17 - 5.6.18, 7.0.3
Monday 2016-03-28<br> Tuesday 2016-03-29<br> Wednesday 2016-03-30<br> Thursday 2016-03-31<br> Friday 2016-04-01<br> Saturday 2016-04-02<br> Sunday 2016-04-03<br>
Output for 5.6.16, 7.0.0 - 7.0.2
Monday 2016-04-04<br> Tuesday 2016-04-05<br> Wednesday 2016-04-06<br> Thursday 2016-04-07<br> Friday 2016-04-08<br> Saturday 2016-04-09<br> Sunday 2016-04-10<br>
Output for 5.5.24 - 5.5.26, 5.6.8 - 5.6.9, 5.6.21
Monday 2016-05-09<br> Tuesday 2016-05-10<br> Wednesday 2016-05-11<br> Thursday 2016-05-12<br> Friday 2016-05-13<br> Saturday 2016-05-14<br> Sunday 2016-05-15<br>
Output for 5.5.34, 5.6.20
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.6.19
Monday 2016-03-14<br> Tuesday 2016-03-15<br> Wednesday 2016-03-16<br> Thursday 2016-03-17<br> Friday 2016-03-18<br> Saturday 2016-03-19<br> Sunday 2016-03-20<br>
Output for 5.5.29, 5.6.13
Monday 2016-04-25<br> Tuesday 2016-04-26<br> Wednesday 2016-04-27<br> Thursday 2016-04-28<br> Friday 2016-04-29<br> Saturday 2016-04-30<br> Sunday 2016-05-01<br>
Output for 5.5.27 - 5.5.28, 5.6.10 - 5.6.12
Monday 2016-05-02<br> Tuesday 2016-05-03<br> Wednesday 2016-05-04<br> Thursday 2016-05-05<br> Friday 2016-05-06<br> Saturday 2016-05-07<br> Sunday 2016-05-08<br>
Output for 5.6.7
Monday 2016-06-06<br> Tuesday 2016-06-07<br> Wednesday 2016-06-08<br> Thursday 2016-06-09<br> Friday 2016-06-10<br> Saturday 2016-06-11<br> Sunday 2016-06-12<br>
Output for 5.5.35
Monday 2016-05-30<br> Tuesday 2016-05-31<br> Wednesday 2016-06-01<br> Thursday 2016-06-02<br> Friday 2016-06-03<br> Saturday 2016-06-04<br> Sunday 2016-06-05<br>
Output for 5.3.0 - 5.4.45
Monday 2015-11-30<br> Tuesday 2015-12-01<br> Wednesday 2015-12-02<br> Thursday 2015-12-03<br> Friday 2015-12-04<br> Saturday 2015-12-05<br> Sunday 2015-12-06<br>
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined method DateTime::sub() in /in/WRnHW on line 8
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/WRnHW 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/WRnHW 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/WRnHW on line 20
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `','' or `';'' in /in/WRnHW on line 20
Process exited with code 255.