3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $start = new DateTime(''); $end = new DateTime('+7 days'); $interval = new DateInterval('P0D'); $period = new DatePeriod($start, $interval, $end); $safety = 0; foreach ($period as $dt) { $safety++; if ($dt->format("N") === 7) { $end->add(new DateInterval('P2D')); } else { echo $dt->format("l Y-m-d") . PHP_EOL; } if ($safety > 7) { break; } }
Output for 5.3.0 - 5.3.27, 5.4.0 - 5.4.17, 5.6.28, 7.0.14 - 7.1.0
Tuesday 2013-08-27 Tuesday 2013-08-27 Tuesday 2013-08-27 Tuesday 2013-08-27 Tuesday 2013-08-27 Tuesday 2013-08-27 Tuesday 2013-08-27 Tuesday 2013-08-27
Output for 7.0.6
Tuesday 2016-05-03 Tuesday 2016-05-03 Tuesday 2016-05-03 Tuesday 2016-05-03 Tuesday 2016-05-03 Tuesday 2016-05-03 Tuesday 2016-05-03 Tuesday 2016-05-03
Output for 7.0.5
Sunday 2016-04-03 Sunday 2016-04-03 Sunday 2016-04-03 Sunday 2016-04-03 Sunday 2016-04-03 Sunday 2016-04-03 Sunday 2016-04-03 Sunday 2016-04-03
Output for 7.0.4
Thursday 2016-03-10 Thursday 2016-03-10 Thursday 2016-03-10 Thursday 2016-03-10 Thursday 2016-03-10 Thursday 2016-03-10 Thursday 2016-03-10 Thursday 2016-03-10
Output for 7.0.3
Friday 2016-03-18 Friday 2016-03-18 Friday 2016-03-18 Friday 2016-03-18 Friday 2016-03-18 Friday 2016-03-18 Friday 2016-03-18 Friday 2016-03-18
Output for 7.0.2
Tuesday 2016-03-22 Tuesday 2016-03-22 Tuesday 2016-03-22 Tuesday 2016-03-22 Tuesday 2016-03-22 Tuesday 2016-03-22 Tuesday 2016-03-22 Tuesday 2016-03-22
Output for 7.0.1
Thursday 2016-03-24 Thursday 2016-03-24 Thursday 2016-03-24 Thursday 2016-03-24 Thursday 2016-03-24 Thursday 2016-03-24 Thursday 2016-03-24 Thursday 2016-03-24
Output for 7.0.0
Sunday 2016-03-27 Sunday 2016-03-27 Sunday 2016-03-27 Sunday 2016-03-27 Sunday 2016-03-27 Sunday 2016-03-27 Sunday 2016-03-27 Sunday 2016-03-27
Output for hhvm-3.12.0
Sunday 2016-03-13 Sunday 2016-03-13 Sunday 2016-03-13 Sunday 2016-03-13 Sunday 2016-03-13 Sunday 2016-03-13 Sunday 2016-03-13 Sunday 2016-03-13
Output for hhvm-3.10.0
Wednesday 2016-03-30 Wednesday 2016-03-30 Wednesday 2016-03-30 Wednesday 2016-03-30 Wednesday 2016-03-30 Wednesday 2016-03-30 Wednesday 2016-03-30 Wednesday 2016-03-30
Output for 5.6.21
Monday 2016-05-02 Monday 2016-05-02 Monday 2016-05-02 Monday 2016-05-02 Monday 2016-05-02 Monday 2016-05-02 Monday 2016-05-02 Monday 2016-05-02
Output for 5.6.20
Sunday 2016-04-10 Sunday 2016-04-10 Sunday 2016-04-10 Sunday 2016-04-10 Sunday 2016-04-10 Sunday 2016-04-10 Sunday 2016-04-10 Sunday 2016-04-10
Output for 5.6.19
Tuesday 2016-03-08 Tuesday 2016-03-08 Tuesday 2016-03-08 Tuesday 2016-03-08 Tuesday 2016-03-08 Tuesday 2016-03-08 Tuesday 2016-03-08 Tuesday 2016-03-08
Output for 5.6.18
Tuesday 2016-03-15 Tuesday 2016-03-15 Tuesday 2016-03-15 Tuesday 2016-03-15 Tuesday 2016-03-15 Tuesday 2016-03-15 Tuesday 2016-03-15 Tuesday 2016-03-15
Output for 5.6.17
Saturday 2016-03-19 Saturday 2016-03-19 Saturday 2016-03-19 Saturday 2016-03-19 Saturday 2016-03-19 Saturday 2016-03-19 Saturday 2016-03-19 Saturday 2016-03-19
Output for 5.6.16
Monday 2016-03-28 Monday 2016-03-28 Monday 2016-03-28 Monday 2016-03-28 Monday 2016-03-28 Monday 2016-03-28 Monday 2016-03-28 Monday 2016-03-28
Output for 5.6.15
Tuesday 2016-03-29 Tuesday 2016-03-29 Tuesday 2016-03-29 Tuesday 2016-03-29 Tuesday 2016-03-29 Tuesday 2016-03-29 Tuesday 2016-03-29 Tuesday 2016-03-29
Output for 5.6.14
Saturday 2016-04-02 Saturday 2016-04-02 Saturday 2016-04-02 Saturday 2016-04-02 Saturday 2016-04-02 Saturday 2016-04-02 Saturday 2016-04-02 Saturday 2016-04-02
Output for 5.6.13
Friday 2016-04-15 Friday 2016-04-15 Friday 2016-04-15 Friday 2016-04-15 Friday 2016-04-15 Friday 2016-04-15 Friday 2016-04-15 Friday 2016-04-15
Output for 5.6.12
Wednesday 2016-04-20 Wednesday 2016-04-20 Wednesday 2016-04-20 Wednesday 2016-04-20 Wednesday 2016-04-20 Wednesday 2016-04-20 Wednesday 2016-04-20 Wednesday 2016-04-20
Output for 5.6.11
Saturday 2016-04-23 Saturday 2016-04-23 Saturday 2016-04-23 Saturday 2016-04-23 Saturday 2016-04-23 Saturday 2016-04-23 Saturday 2016-04-23 Saturday 2016-04-23
Output for 5.6.10
Monday 2016-04-25 Monday 2016-04-25 Monday 2016-04-25 Monday 2016-04-25 Monday 2016-04-25 Monday 2016-04-25 Monday 2016-04-25 Monday 2016-04-25
Output for 5.6.9
Wednesday 2016-04-27 Wednesday 2016-04-27 Wednesday 2016-04-27 Wednesday 2016-04-27 Wednesday 2016-04-27 Wednesday 2016-04-27 Wednesday 2016-04-27 Wednesday 2016-04-27
Output for 5.6.8
Saturday 2016-04-30 Saturday 2016-04-30 Saturday 2016-04-30 Saturday 2016-04-30 Saturday 2016-04-30 Saturday 2016-04-30 Saturday 2016-04-30 Saturday 2016-04-30
Output for 5.5.35
Sunday 2016-05-22 Sunday 2016-05-22 Sunday 2016-05-22 Sunday 2016-05-22 Sunday 2016-05-22 Sunday 2016-05-22 Sunday 2016-05-22 Sunday 2016-05-22
Output for 5.5.34
Monday 2016-04-11 Monday 2016-04-11 Monday 2016-04-11 Monday 2016-04-11 Monday 2016-04-11 Monday 2016-04-11 Monday 2016-04-11 Monday 2016-04-11
Output for 5.5.33
Wednesday 2016-03-09 Wednesday 2016-03-09 Wednesday 2016-03-09 Wednesday 2016-03-09 Wednesday 2016-03-09 Wednesday 2016-03-09 Wednesday 2016-03-09 Wednesday 2016-03-09
Output for 5.5.32
Thursday 2016-03-17 Thursday 2016-03-17 Thursday 2016-03-17 Thursday 2016-03-17 Thursday 2016-03-17 Thursday 2016-03-17 Thursday 2016-03-17 Thursday 2016-03-17
Output for 5.5.31
Monday 2016-03-21 Monday 2016-03-21 Monday 2016-03-21 Monday 2016-03-21 Monday 2016-03-21 Monday 2016-03-21 Monday 2016-03-21 Monday 2016-03-21
Output for 5.5.30
Friday 2016-04-01 Friday 2016-04-01 Friday 2016-04-01 Friday 2016-04-01 Friday 2016-04-01 Friday 2016-04-01 Friday 2016-04-01 Friday 2016-04-01
Output for 5.5.29
Sunday 2016-04-17 Sunday 2016-04-17 Sunday 2016-04-17 Sunday 2016-04-17 Sunday 2016-04-17 Sunday 2016-04-17 Sunday 2016-04-17 Sunday 2016-04-17
Output for 5.5.28
Thursday 2016-04-21 Thursday 2016-04-21 Thursday 2016-04-21 Thursday 2016-04-21 Thursday 2016-04-21 Thursday 2016-04-21 Thursday 2016-04-21 Thursday 2016-04-21
Output for 5.5.27
Friday 2016-04-22 Friday 2016-04-22 Friday 2016-04-22 Friday 2016-04-22 Friday 2016-04-22 Friday 2016-04-22 Friday 2016-04-22 Friday 2016-04-22
Output for 5.5.26
Tuesday 2016-04-26 Tuesday 2016-04-26 Tuesday 2016-04-26 Tuesday 2016-04-26 Tuesday 2016-04-26 Tuesday 2016-04-26 Tuesday 2016-04-26 Tuesday 2016-04-26
Output for 5.5.25
Thursday 2016-04-28 Thursday 2016-04-28 Thursday 2016-04-28 Thursday 2016-04-28 Thursday 2016-04-28 Thursday 2016-04-28 Thursday 2016-04-28 Thursday 2016-04-28
Output for 5.5.24
Tuesday 2016-05-24 Tuesday 2016-05-24 Tuesday 2016-05-24 Tuesday 2016-05-24 Tuesday 2016-05-24 Tuesday 2016-05-24 Tuesday 2016-05-24 Tuesday 2016-05-24
Output for 5.4.45
Sunday 2015-09-20 Sunday 2015-09-20 Sunday 2015-09-20 Sunday 2015-09-20 Sunday 2015-09-20 Sunday 2015-09-20 Sunday 2015-09-20 Sunday 2015-09-20
Output for 5.4.39 - 5.4.44
Monday 2015-08-10 Monday 2015-08-10 Monday 2015-08-10 Monday 2015-08-10 Monday 2015-08-10 Monday 2015-08-10 Monday 2015-08-10 Monday 2015-08-10
Output for 5.4.34 - 5.4.38
Tuesday 2015-03-03 Tuesday 2015-03-03 Tuesday 2015-03-03 Tuesday 2015-03-03 Tuesday 2015-03-03 Tuesday 2015-03-03 Tuesday 2015-03-03 Tuesday 2015-03-03
Output for 5.3.28 - 5.3.29, 5.4.18 - 5.4.32
Thursday 2014-09-11 Thursday 2014-09-11 Thursday 2014-09-11 Thursday 2014-09-11 Thursday 2014-09-11 Thursday 2014-09-11 Thursday 2014-09-11 Thursday 2014-09-11
Output for 5.2.0 - 5.2.17
Fatal error: Class 'DateInterval' not found in /in/GA4It on line 4
Process exited with code 255.
Output for 5.0.0 - 5.1.6
Fatal error: Class 'DateTime' not found in /in/GA4It on line 2
Process exited with code 255.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: datetime in /in/GA4It on line 2
Process exited with code 255.
Output for 4.3.1
Fatal error: Cannot instantiate non-existent class: datetime in /in/GA4It on line 2
Output for 4.3.0
Fatal error: Cannot instantiate non-existent class: datetime in /in/N9lqB on line 2