3v4l.org

run code in 300+ PHP versions simultaneously
<?php $fillStart = new DateTime("2020-09-27 12:34:56"); $fillEnd = new DateTime("2020-10-10 12:34:56"); $gapStart = new DateTime("2020-09-09 01:02:03"); $gapEnd = new DateTime("2020-09-11 04:05:06"); // // 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 %30s -> %30s\n", $fillStart->format($f), $fillEnd->format($f)); printf("Gap %30s -> %30s\n", $gapStart->format($f), $gapEnd->format($f)); printf("New %30s -> %30s\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/UJJfa on line 27 Fill Sunday 2020-09-27 12:34:56 -> Saturday 2020-10-10 12:34:56 Gap Wednesday 2020-09-09 01:02:03 -> Friday 2020-09-11 04:05:06 New Wednesday 2020-09-30 01:02:03 -> Friday 2020-10-02 04:05:06

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