3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $begin = new DateTime( '2007-10-20' ); $end = new DateTime( '2007-12-31' ); $interval = DateInterval::createFromDateString('1 month'); //$interval = new DateInterval('P1M'); $period = new DatePeriod(DateTime::createFromFormat('Y-m-d', $begin->format('Y-m-1')), $interval, $end); foreach ( $period as $dt ) { echo $dt->format( "l Y-m-d H:i:s\n" ); }
based on PYn4g
Output for 5.6.28, 7.0.20 - 7.2.0
Monday 2007-10-01 12:56:47 Thursday 2007-11-01 12:56:47 Saturday 2007-12-01 12:56:47
Output for 7.0.6
Monday 2007-10-01 19:49:25 Thursday 2007-11-01 19:49:25 Saturday 2007-12-01 19:49:25
Output for 7.0.5
Monday 2007-10-01 08:09:31 Thursday 2007-11-01 08:09:31 Saturday 2007-12-01 08:09:31
Output for 7.0.4
Monday 2007-10-01 20:03:20 Thursday 2007-11-01 20:03:20 Saturday 2007-12-01 20:03:20
Output for 7.0.3
Monday 2007-10-01 21:24:06 Thursday 2007-11-01 21:24:06 Saturday 2007-12-01 21:24:06
Output for 7.0.2
Monday 2007-10-01 03:37:54 Thursday 2007-11-01 03:37:54 Saturday 2007-12-01 03:37:54
Output for 7.0.1
Monday 2007-10-01 06:55:12 Thursday 2007-11-01 06:55:12 Saturday 2007-12-01 06:55:12
Output for 7.0.0
Monday 2007-10-01 08:49:53 Thursday 2007-11-01 08:49:53 Saturday 2007-12-01 08:49:53
Output for 5.6.21
Monday 2007-10-01 14:57:32 Thursday 2007-11-01 14:57:32 Saturday 2007-12-01 14:57:32
Output for 5.6.20
Monday 2007-10-01 07:10:37 Thursday 2007-11-01 07:10:37 Saturday 2007-12-01 07:10:37
Output for 5.6.19
Monday 2007-10-01 04:15:51 Thursday 2007-11-01 04:15:51 Saturday 2007-12-01 04:15:51
Output for 5.6.18
Monday 2007-10-01 13:06:02 Thursday 2007-11-01 13:06:02 Saturday 2007-12-01 13:06:02
Output for 5.6.17
Monday 2007-10-01 00:40:58 Thursday 2007-11-01 00:40:58 Saturday 2007-12-01 00:40:58
Output for 5.6.16
Monday 2007-10-01 09:38:58 Thursday 2007-11-01 09:38:58 Saturday 2007-12-01 09:38:58
Output for 5.6.15
Monday 2007-10-01 10:28:33 Thursday 2007-11-01 10:28:33 Saturday 2007-12-01 10:28:33
Output for 5.6.14
Monday 2007-10-01 12:18:50 Thursday 2007-11-01 12:18:50 Saturday 2007-12-01 12:18:50
Output for 5.6.13
Monday 2007-10-01 16:50:04 Thursday 2007-11-01 16:50:04 Saturday 2007-12-01 16:50:04
Output for 5.6.12
Monday 2007-10-01 07:16:47 Thursday 2007-11-01 07:16:47 Saturday 2007-12-01 07:16:47
Output for 5.6.11
Monday 2007-10-01 13:41:25 Thursday 2007-11-01 13:41:25 Saturday 2007-12-01 13:41:25
Output for 5.6.10
Monday 2007-10-01 15:45:02 Thursday 2007-11-01 15:45:02 Saturday 2007-12-01 15:45:02
Output for 5.6.9
Monday 2007-10-01 20:53:37 Thursday 2007-11-01 20:53:37 Saturday 2007-12-01 20:53:37
Output for 5.6.8
Monday 2007-10-01 05:42:46 Thursday 2007-11-01 05:42:46 Saturday 2007-12-01 05:42:46
Output for 5.5.35
Monday 2007-10-01 23:48:56 Thursday 2007-11-01 23:48:56 Saturday 2007-12-01 23:48:56
Output for 5.5.34
Monday 2007-10-01 09:22:01 Thursday 2007-11-01 09:22:01 Saturday 2007-12-01 09:22:01
Output for 5.5.33
Monday 2007-10-01 07:08:21 Thursday 2007-11-01 07:08:21 Saturday 2007-12-01 07:08:21
Output for 5.5.32
Monday 2007-10-01 16:57:01 Thursday 2007-11-01 16:57:01 Saturday 2007-12-01 16:57:01
Output for 5.5.31
Monday 2007-10-01 03:46:21 Thursday 2007-11-01 03:46:21 Saturday 2007-12-01 03:46:21
Output for 5.5.30
Monday 2007-10-01 12:21:25 Thursday 2007-11-01 12:21:25 Saturday 2007-12-01 12:21:25
Output for 5.5.29
Monday 2007-10-01 07:08:02 Thursday 2007-11-01 07:08:02 Saturday 2007-12-01 07:08:02
Output for 5.5.28
Monday 2007-10-01 10:32:32 Thursday 2007-11-01 10:32:32 Saturday 2007-12-01 10:32:32
Output for 5.5.27
Monday 2007-10-01 12:15:16 Thursday 2007-11-01 12:15:16 Saturday 2007-12-01 12:15:16
Output for 5.5.26
Monday 2007-10-01 18:25:54 Thursday 2007-11-01 18:25:54 Saturday 2007-12-01 18:25:54
Output for 5.5.25
Monday 2007-10-01 01:49:22 Thursday 2007-11-01 01:49:22 Saturday 2007-12-01 01:49:22
Output for 5.5.24
Monday 2007-10-01 08:00:37 Thursday 2007-11-01 08:00:37 Saturday 2007-12-01 08:00:37
Output for 5.4.45
Monday 2007-10-01 12:56:50 Thursday 2007-11-01 12:56:50 Saturday 2007-12-01 12:56:50
Output for 5.4.44
Monday 2007-10-01 12:56:51 Thursday 2007-11-01 12:56:51 Saturday 2007-12-01 12:56:51
Output for 5.4.42 - 5.4.43
Monday 2007-10-01 12:56:52 Thursday 2007-11-01 12:56:52 Saturday 2007-12-01 12:56:52
Output for 5.4.40 - 5.4.41
Monday 2007-10-01 12:56:53 Thursday 2007-11-01 12:56:53 Saturday 2007-12-01 12:56:53
Output for 5.4.36 - 5.4.39
Monday 2007-10-01 12:56:54 Thursday 2007-11-01 12:56:54 Saturday 2007-12-01 12:56:54
Output for 5.4.34 - 5.4.35
Monday 2007-10-01 12:56:55 Thursday 2007-11-01 12:56:55 Saturday 2007-12-01 12:56:55
Output for 5.3.29, 5.4.31 - 5.4.32
Monday 2007-10-01 12:56:56 Thursday 2007-11-01 12:56:56 Saturday 2007-12-01 12:56:56
Output for 5.4.25 - 5.4.30
Monday 2007-10-01 12:56:57 Thursday 2007-11-01 12:56:57 Saturday 2007-12-01 12:56:57
Output for 5.3.28, 5.4.21 - 5.4.24
Monday 2007-10-01 12:56:58 Thursday 2007-11-01 12:56:58 Saturday 2007-12-01 12:56:58
Output for 5.3.27, 5.4.17 - 5.4.20
Monday 2007-10-01 12:56:59 Thursday 2007-11-01 12:56:59 Saturday 2007-12-01 12:56:59
Output for 5.3.24 - 5.3.26, 5.4.13 - 5.4.16
Monday 2007-10-01 12:57:00 Thursday 2007-11-01 12:57:00 Saturday 2007-12-01 12:57:00
Output for 5.3.20 - 5.3.23, 5.4.10 - 5.4.12
Monday 2007-10-01 12:57:01 Thursday 2007-11-01 12:57:01 Saturday 2007-12-01 12:57:01