3v4l.org

run code in 300+ PHP versions simultaneously
<?php function isWeekend($date) { if ($date instanceof DateTime) { $date = DateTimeImmutable::createFromMutable($date); } return $date->setTime(0,0,0) != $date->modify('this weekday'); } function isWeekendUnixTimestamp($dateValue) { return date('Yz', strtotime($dateValue)) != date('Yz', strtotime($dateValue . ' this weekday')); } echo 'DateTimeInterface Comparison:' . PHP_EOL; $sunday = new DateTimeImmutable('Sunday'); $periods = new DatePeriod($sunday, new DateInterval('P1D'), 6); foreach ($periods as $date) { echo $date->format('D') . ' is' . (isWeekend($date) ? '' : ' not') . ' a weekend' . PHP_EOL; } echo PHP_EOL . 'String Comparison:' . PHP_EOL; foreach ($periods as $date) { echo $date->format('D') . ' is' . (isWeekendUnixTimestamp($date->format('Y-m-d')) ? '' : ' not') . ' a weekend' . PHP_EOL; }
Output for git.master, git.master_jit, rfc.property-hooks
DateTimeInterface Comparison: Sun is a weekend Mon is not a weekend Tue is not a weekend Wed is not a weekend Thu is not a weekend Fri is not a weekend Sat is a weekend String Comparison: Sun is a weekend Mon is not a weekend Tue is not a weekend Wed is not a weekend Thu is not a weekend Fri is not a weekend Sat is a weekend

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:
47.06 ms | 402 KiB | 8 Q