3v4l.org

run code in 150+ 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 = 0; $i <= 6; $i++) { echo $date->add(new DateInterval('P1D'))->format('l Y-m-d') . "<br>\n"; } ?>
Output for 5.3.0 - 5.3.28, 5.4.0 - 5.4.30, 5.6.28, 7.0.14 - 7.1.0
Monday 2014-06-30<br> Tuesday 2014-07-01<br> Wednesday 2014-07-02<br> Thursday 2014-07-03<br> Friday 2014-07-04<br> Saturday 2014-07-05<br> Sunday 2014-07-06<br>
Output for 7.0.6
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.5.30, 5.6.14 - 5.6.15, 7.0.5
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.5.33, 5.6.19, 7.0.4
Monday 2016-03-07<br> Tuesday 2016-03-08<br> Wednesday 2016-03-09<br> Thursday 2016-03-10<br> Friday 2016-03-11<br> Saturday 2016-03-12<br> Sunday 2016-03-13<br>
Output for 5.5.31 - 5.5.32, 5.6.17 - 5.6.18, 7.0.3
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.6.16, 7.0.0 - 7.0.2
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.24 - 5.5.26, 5.6.8 - 5.6.9, 5.6.21
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.34, 5.6.20
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.29, 5.6.13
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.27 - 5.5.28, 5.6.10 - 5.6.12
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.7
Monday 2016-05-23<br> Tuesday 2016-05-24<br> Wednesday 2016-05-25<br> Thursday 2016-05-26<br> Friday 2016-05-27<br> Saturday 2016-05-28<br> Sunday 2016-05-29<br>
Output for 5.5.35
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.4.41 - 5.4.45
Monday 2015-09-21<br> Tuesday 2015-09-22<br> Wednesday 2015-09-23<br> Thursday 2015-09-24<br> Friday 2015-09-25<br> Saturday 2015-09-26<br> Sunday 2015-09-27<br>
Output for 5.4.39 - 5.4.40
Monday 2015-09-14<br> Tuesday 2015-09-15<br> Wednesday 2015-09-16<br> Thursday 2015-09-17<br> Friday 2015-09-18<br> Saturday 2015-09-19<br> Sunday 2015-09-20<br>
Output for 5.4.34 - 5.4.38
Monday 2015-03-02<br> Tuesday 2015-03-03<br> Wednesday 2015-03-04<br> Thursday 2015-03-05<br> Friday 2015-03-06<br> Saturday 2015-03-07<br> Sunday 2015-03-08<br>
Output for 5.3.29, 5.4.31 - 5.4.32
Monday 2014-09-08<br> Tuesday 2014-09-09<br> Wednesday 2014-09-10<br> Thursday 2014-09-11<br> Friday 2014-09-12<br> Saturday 2014-09-13<br> Sunday 2014-09-14<br>
Output for 5.2.0 - 5.2.17
Fatal error: Call to undefined method DateTime::sub() in /in/SoCj1 on line 8
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/SoCj1 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/SoCj1 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/SoCj1 on line 20
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `','' or `';'' in /in/SoCj1 on line 20
Process exited with code 255.