3v4l.org

run code in 300+ PHP versions simultaneously
<?php $start_date = '2014-01-01'; $end_date = '2015-01-31'; $date_regex = "/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/"; if (!empty($start_date) & !empty($end_date) && preg_match($date_regex, $start_date) && preg_match($date_regex, $end_date)) { $start = new \DateTime($start_date); $end = new \DateTime($end_date); $now = new \DateTime(); $intervals = []; while ($start <= $end) { $first_day = $start->format('Y-m-d'); if ( $start->format('Y-m') === $now->format('Y-m') ) { $last_day = $now->format('Y-m-d'); } else { $last_day = date('Y-m-t', strtotime($start->format('Y-m'))); } $intervals[ $first_day ] = $last_day; $start->modify('first day of next month'); } echo '<pre>';print_r($intervals); }
Output for git.master, git.master_jit, rfc.property-hooks
<pre>Array ( [2014-01-01] => 2014-01-31 [2014-02-01] => 2014-02-28 [2014-03-01] => 2014-03-31 [2014-04-01] => 2014-04-30 [2014-05-01] => 2014-05-31 [2014-06-01] => 2014-06-30 [2014-07-01] => 2014-07-31 [2014-08-01] => 2014-08-31 [2014-09-01] => 2014-09-30 [2014-10-01] => 2014-10-31 [2014-11-01] => 2014-11-30 [2014-12-01] => 2014-12-31 [2015-01-01] => 2015-01-14 )

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
48.61 ms | 402 KiB | 8 Q