3v4l.org

run code in 300+ PHP versions simultaneously
<?php print_r(getPeroid()); // Example 1 print_r(getPeroid()->start); // Example 3 print_r(getPeroid(new DateTime("2013-02-14"))); // Example 2 function getPeroid(\Datetime $date = null, DateInterval $interval = null) { $interval = $interval ? : new DateInterval('P7D'); $end = $date ? : new DateTime(); $end->modify("Last Sunday"); $start = clone $end; $start->sub($interval); return (object) array( "start" => $start->format("l, d F Y"), "end" => $end->format("l, d F Y") ); } function getPeriodBetween(Datetime $start = null, Datetime $end = null, DateInterval $interval = null) { $interval = $interval ? : new DateInterval('P7D'); if ($start === null) { $start = new DateTime(); $start->modify("First Sunday of January"); } else { $start->modify("First Sunday"); } if ($end === null) { $end = new DateTime(); $end->modify("Last Sunday of December"); } $range = array(); while ( $start < $end ) { $r = (object) array( "start" => $start->format("l, d F Y") ); $start->add($interval); $r->end = $start->format("l, d F Y"); $range[] = $r; } return $range; }
Output for git.master, git.master_jit, rfc.property-hooks
stdClass Object ( [start] => Sunday, 31 March 2013 [end] => Sunday, 07 April 2013 ) Sunday, 31 March 2013stdClass Object ( [start] => Sunday, 03 February 2013 [end] => Sunday, 10 February 2013 )

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:
42.75 ms | 401 KiB | 8 Q