3v4l.org

run code in 300+ PHP versions simultaneously
<?php $order_date = '2020-07-09 10:23:00'; // if no argument the, use the current time function getPossibleShippingDates($order_date = 'now', $num_day = 3) { $dates = []; $dt = new DateTime($order_date); if ($dt->format('H') >= 10) { // if ordered on or after 10, move to next day $dt->modify('+1 day'); } if (in_array($dt->format('N'), [6, 7])) { // if ordered weekend, adjust to start monday $dt->modify('next monday'); } $i = 1; while ($i <= $num_day) { if (!in_array($dt->format('N'), [6, 7])) { $dates[$i++] = $dt->format('Y-m-d'); } $dt->modify('+1 day'); } return $dates; } $dates = getPossibleShippingDates($order_date); print_r($dates);
Output for git.master_jit, git.master, rfc.property-hooks
Array ( [1] => 2020-07-10 [2] => 2020-07-13 [3] => 2020-07-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:
33.28 ms | 405 KiB | 5 Q