3v4l.org

run code in 300+ PHP versions simultaneously
<?php $fillStart = new DateTime("2019-07-23 00:15:00"); $fillEnd = new DateTime("2019-09-23 13:00:00"); $gapStart = new DateTime("2019-05-23 00:15:00"); $gapEnd = new DateTime("2019-06-23 13:00:00"); // // being with the original start $fillStartModified = clone $fillStart; // move to the next weekday and time $wdtStart = $gapStart->format("l H:i:s"); if ($fillStartModified->format("l H:i:s") != $wdtStart) { $fillStartModified->modify("next {$wdtStart}"); } // get the duration, minus a bit so we can do a "next <day>" after $days = $gapStart->diff($gapEnd)->days - 1; // get the weekday and time $wdtEnd = $gapEnd->format("l H:i:s"); // update $fillEndModified = clone $fillStartModified; $fillEndModified->modify("+${days} days"); $fillEndModified->modify("next {$wdtEnd}"); $f = "l Y-m-d H:i:s"; printf("Fill %28s -> %28s\n", $fillStart->format($f), $fillEnd->format($f)); printf("Gap %28s -> %28s\n", $gapStart->format($f), $gapEnd->format($f)); printf("New %28s -> %28s\n", $fillStartModified->format($f), $fillEndModified->format($f));
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /in/7JDgp on line 27 Fill Tuesday 2019-07-23 00:15:00 -> Monday 2019-09-23 13:00:00 Gap Thursday 2019-05-23 00:15:00 -> Sunday 2019-06-23 13:00:00 New Thursday 2019-07-25 00:15:00 -> Sunday 2019-08-25 13:00:00

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