3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $start = new DateTime(); $interval = new DateInterval('P2W'); $period = new DatePeriod( $start, $interval, 3, DatePeriod::EXCLUDE_START_DATE ); foreach ($period as $nextDateTime) { echo $nextDateTime->format('Y-m-d H:i:s'), PHP_EOL; }
based on QPfRS
Output for 5.6.28, 7.0.20 - 7.2.0
2015-10-30 11:28:00 2015-11-13 11:28:00 2015-11-27 11:28:00
Output for 7.0.6
2016-05-17 12:13:01 2016-05-31 12:13:01 2016-06-14 12:13:01
Output for 7.0.5
2016-04-17 00:56:49 2016-05-01 00:56:49 2016-05-15 00:56:49
Output for 7.0.4
2016-03-24 11:39:41 2016-04-07 11:39:41 2016-04-21 11:39:41
Output for 7.0.3
2016-04-01 12:23:19 2016-04-15 12:23:19 2016-04-29 12:23:19
Output for 7.0.2
2016-04-05 18:21:03 2016-04-19 18:21:03 2016-05-03 18:21:03
Output for 7.0.1
2016-04-06 22:44:17 2016-04-20 22:44:17 2016-05-04 22:44:17
Output for 7.0.0
2016-04-10 00:13:49 2016-04-24 00:13:49 2016-05-08 00:13:49
Output for 5.6.21
2016-05-16 07:26:16 2016-05-30 07:26:16 2016-06-13 07:26:16
Output for 5.6.20
2016-04-23 23:47:50 2016-05-07 23:47:50 2016-05-21 23:47:50
Output for 5.6.19
2016-03-21 19:41:45 2016-04-04 19:41:45 2016-04-18 19:41:45
Output for 5.6.18
2016-03-29 04:15:37 2016-04-12 04:15:37 2016-04-26 04:15:37
Output for 5.6.17
2016-04-02 16:32:06 2016-04-16 16:32:06 2016-04-30 16:32:06
Output for 5.6.16
2016-04-11 02:11:31 2016-04-25 02:11:31 2016-05-09 02:11:31
Output for 5.6.15
2016-04-12 03:07:11 2016-04-26 03:07:11 2016-05-10 03:07:11
Output for 5.6.14
2016-04-16 05:18:34 2016-04-30 05:18:34 2016-05-14 05:18:34
Output for 5.6.13
2016-04-29 09:17:39 2016-05-13 09:17:39 2016-05-27 09:17:39
Output for 5.6.12
2016-05-03 23:15:00 2016-05-17 23:15:00 2016-05-31 23:15:00
Output for 5.6.11
2016-05-07 06:11:07 2016-05-21 06:11:07 2016-06-04 06:11:07
Output for 5.6.10
2016-05-09 07:57:38 2016-05-23 07:57:38 2016-06-06 07:57:38
Output for 5.6.9
2016-05-11 13:01:27 2016-05-25 13:01:27 2016-06-08 13:01:27
Output for 5.6.8
2016-05-13 21:11:55 2016-05-27 21:11:55 2016-06-10 21:11:55
Output for 5.5.35
2016-06-05 11:12:44 2016-06-19 11:12:44 2016-07-03 11:12:44
Output for 5.5.34
2016-04-25 02:09:11 2016-05-09 02:09:11 2016-05-23 02:09:11
Output for 5.5.33
2016-03-22 22:39:51 2016-04-05 22:39:51 2016-04-19 22:39:51
Output for 5.5.32
2016-03-31 06:18:39 2016-04-14 06:18:39 2016-04-28 06:18:39
Output for 5.5.31
2016-04-03 19:15:24 2016-04-17 19:15:24 2016-05-01 19:15:24
Output for 5.5.30
2016-04-15 05:01:44 2016-04-29 05:01:44 2016-05-13 05:01:44
Output for 5.5.29
2016-04-30 23:25:40 2016-05-14 23:25:40 2016-05-28 23:25:40
Output for 5.5.28
2016-05-05 02:35:00 2016-05-19 02:35:00 2016-06-02 02:35:00
Output for 5.5.27
2016-05-06 04:52:01 2016-05-20 04:52:01 2016-06-03 04:52:01
Output for 5.5.26
2016-05-10 10:29:47 2016-05-24 10:29:47 2016-06-07 10:29:47
Output for 5.5.25
2016-05-12 16:56:16 2016-05-26 16:56:16 2016-06-09 16:56:16
Output for 5.5.24
2016-06-07 00:04:01 2016-06-21 00:04:01 2016-07-05 00:04:01
Output for 5.4.43 - 5.4.45
2015-10-30 11:28:10 2015-11-13 11:28:10 2015-11-27 11:28:10
Output for 5.4.36 - 5.4.42
2015-10-30 11:28:11 2015-11-13 11:28:11 2015-11-27 11:28:11
Output for 5.4.28 - 5.4.35
2015-10-30 11:28:12 2015-11-13 11:28:12 2015-11-27 11:28:12
Output for 5.4.21 - 5.4.27
2015-10-30 11:28:13 2015-11-13 11:28:13 2015-11-27 11:28:13
Output for 5.4.14 - 5.4.20
2015-10-30 11:28:14 2015-11-13 11:28:14 2015-11-27 11:28:14
Output for 5.4.8 - 5.4.13
2015-10-30 11:28:15 2015-11-13 11:28:15 2015-11-27 11:28:15
Output for 5.4.7
2015-11-10 02:01:03 2015-11-24 02:01:03 2015-12-08 02:01:03
Output for 5.4.6
2015-11-10 03:29:32 2015-11-24 03:29:32 2015-12-08 03:29:32
Output for 5.4.5
2015-11-10 04:59:47 2015-11-24 04:59:47 2015-12-08 04:59:47
Output for 5.4.4
2015-11-10 06:37:01 2015-11-24 06:37:01 2015-12-08 06:37:01
Output for 5.4.3
2015-11-10 08:18:26 2015-11-24 08:18:26 2015-12-08 08:18:26
Output for 5.4.2
2015-11-10 10:03:15 2015-11-24 10:03:15 2015-12-08 10:03:15
Output for 5.3.29
2015-11-14 06:00:47 2015-11-28 06:00:47 2015-12-12 06:00:47
Output for 5.3.28
2015-11-14 08:09:30 2015-11-28 08:09:30 2015-12-12 08:09:30
Output for 5.3.27
2015-11-16 07:11:00 2015-11-30 07:11:00 2015-12-14 07:11:00
Output for 5.3.26
2015-11-16 09:12:13 2015-11-30 09:12:13 2015-12-14 09:12:13
Output for 5.3.25
2015-11-16 10:42:49 2015-11-30 10:42:49 2015-12-14 10:42:49
Output for 5.3.24
2015-11-16 11:54:20 2015-11-30 11:54:20 2015-12-14 11:54:20
Output for 5.3.23
2015-11-16 13:30:18 2015-11-30 13:30:18 2015-12-14 13:30:18
Output for 5.3.22
2015-11-16 15:01:44 2015-11-30 15:01:44 2015-12-14 15:01:44
Output for 5.3.21
2015-11-16 16:01:55 2015-11-30 16:01:55 2015-12-14 16:01:55
Output for 5.3.20
2015-11-16 17:02:13 2015-11-30 17:02:13 2015-12-14 17:02:13
Output for 5.3.19
2015-11-16 18:27:33 2015-11-30 18:27:33 2015-12-14 18:27:33
Output for 5.3.18
2015-11-16 18:34:11 2015-11-30 18:34:11 2015-12-14 18:34:11