3v4l.org

run code in 300+ PHP versions simultaneously
<?php //echo date('r', strtotime('last sunday', strtotime('6 April 1991'))); function align_timestamp_to($stamp, $unit, $past){ // timestamp, unit string, start/end static $modes = array( 'week' => 'last monday', 'month' => 'first day of month', ); // TODO error out if unknown $unit $offset = $modes[$unit]; if($past == 'end')$offset = '+1 '.$unit.' '.$offset; $new = strtotime($offset, $stamp); } foreach(array( array(strtotime('4 Apr 2012'), 'week', 'start'), array(strtotime('4 Apr 2012'), 'week', 'end'), ) as $test)echo date('r', $test[0]).' aligned '.$test[2].' of '.$test[1].' yields '.date('r', align_timestamp_to($test[0], $test[1], $test[2])).'<br/>';
Output for git.master, git.master_jit, rfc.property-hooks
Wed, 04 Apr 2012 00:00:00 +0200 aligned start of week yields Fri, 30 Nov 2012 14:17:15 +0100<br/>Wed, 04 Apr 2012 00:00:00 +0200 aligned end of week yields Fri, 30 Nov 2012 14:17:15 +0100<br/>

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