3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DTBug { private $intervals = [ '1min' => null, '1day' => null, '1wk' => null, ]; private $inspectCalc; public function __construct($inspectStored=false, $inspectCalc=false) { $this->inspectCalc = $inspectCalc; $this->intervals['1min'] = new \DateInterval("PT1M"); $this->intervals['1day'] = new \DateInterval("P1D"); $this->intervals['1wk'] = new \DateInterval("P7D"); if ($inspectStored) { array_map(function($s) { var_export($s, true); }, $this->intervals); } } public function compare(DateTimeInterface $start, DateTimeInterface $end) { $diff = $start->diff($end, true); if ($this->inspectCalc) { var_export($diff, true); } if ($diff < $this->intervals['1min']) { $op = "less than a minute"; } elseif ($diff < $this->intervals['1day']) { $op = "between an minute and a day"; } elseif ($diff < $this->intervals['1wk']) { $op = "between a day and a week"; } else { $op = "greater than a week"; } $this->output($start, $end, $op); } private function output(DateTimeInterface $start, DateTimeInterface $end, $op) { echo $start->format("Y-m-d H:i:s")." is ".$op." from ".$end->format("Y-m-d H:i:s")."\n"; } } echo "\nTesting without looking at the intervals:\n"; $bug = new DTBug; $bug->compare(new DateTimeImmutable("2016-05-16 09:12:32"), new DateTimeImmutable("2016-05-16 09:13:35")); // 1min 3sec $bug->compare(new DateTimeImmutable("2016-05-16 09:12:32"), new DateTimeImmutable("2016-05-16 12:13:35")); // 3hrs 1min 3sec $bug->compare(new DateTimeImmutable("2016-05-16 09:12:32"), new DateTimeImmutable("2016-05-18 09:13:35")); // 2day 1min 3sec $bug->compare(new DateTimeImmutable("2016-05-16 09:12:32"), new DateTimeImmutable("2016-07-16 09:13:35")); // 2mon 1min 3sec echo "\nTesting whilst looking at the stored intervals:\n"; $debug = new DTBug(true); $debug->compare(new DateTimeImmutable("2016-05-16 09:12:32"), new DateTimeImmutable("2016-05-16 09:13:35")); // 1min 3sec $debug->compare(new DateTimeImmutable("2016-05-16 09:12:32"), new DateTimeImmutable("2016-05-16 12:13:35")); // 3hrs 1min 3sec $debug->compare(new DateTimeImmutable("2016-05-16 09:12:32"), new DateTimeImmutable("2016-05-18 09:13:35")); // 2day 1min 3sec $debug->compare(new DateTimeImmutable("2016-05-16 09:12:32"), new DateTimeImmutable("2016-07-16 09:13:35")); // 2mon 1min 3sec echo "\nTesting whilst looking at the calculated intervals only:\n"; $debug = new DTBug(false, true); $debug->compare(new DateTimeImmutable("2016-05-16 09:12:32"), new DateTimeImmutable("2016-05-16 09:13:35")); // 1min 3sec $debug->compare(new DateTimeImmutable("2016-05-16 09:12:32"), new DateTimeImmutable("2016-05-16 12:13:35")); // 3hrs 1min 3sec $debug->compare(new DateTimeImmutable("2016-05-16 09:12:32"), new DateTimeImmutable("2016-05-18 09:13:35")); // 2day 1min 3sec $debug->compare(new DateTimeImmutable("2016-05-16 09:12:32"), new DateTimeImmutable("2016-07-16 09:13:35")); // 2mon 1min 3sec echo "\nTesting whilst looking at the both intervals:\n"; $debug = new DTBug(true, true); $debug->compare(new DateTimeImmutable("2016-05-16 09:12:32"), new DateTimeImmutable("2016-05-16 09:13:35")); // 1min 3sec $debug->compare(new DateTimeImmutable("2016-05-16 09:12:32"), new DateTimeImmutable("2016-05-16 12:13:35")); // 3hrs 1min 3sec $debug->compare(new DateTimeImmutable("2016-05-16 09:12:32"), new DateTimeImmutable("2016-05-18 09:13:35")); // 2day 1min 3sec $debug->compare(new DateTimeImmutable("2016-05-16 09:12:32"), new DateTimeImmutable("2016-07-16 09:13:35")); // 2mon 1min 3sec
Output for git.master, git.master_jit, rfc.property-hooks
Testing without looking at the intervals: Warning: Cannot compare DateInterval objects in /in/TrPvp on line 29 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 31 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 33 2016-05-16 09:12:32 is greater than a week from 2016-05-16 09:13:35 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 29 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 31 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 33 2016-05-16 09:12:32 is greater than a week from 2016-05-16 12:13:35 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 29 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 31 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 33 2016-05-16 09:12:32 is greater than a week from 2016-05-18 09:13:35 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 29 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 31 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 33 2016-05-16 09:12:32 is greater than a week from 2016-07-16 09:13:35 Testing whilst looking at the stored intervals: Warning: Cannot compare DateInterval objects in /in/TrPvp on line 29 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 31 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 33 2016-05-16 09:12:32 is greater than a week from 2016-05-16 09:13:35 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 29 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 31 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 33 2016-05-16 09:12:32 is greater than a week from 2016-05-16 12:13:35 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 29 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 31 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 33 2016-05-16 09:12:32 is greater than a week from 2016-05-18 09:13:35 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 29 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 31 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 33 2016-05-16 09:12:32 is greater than a week from 2016-07-16 09:13:35 Testing whilst looking at the calculated intervals only: Warning: Cannot compare DateInterval objects in /in/TrPvp on line 29 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 31 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 33 2016-05-16 09:12:32 is greater than a week from 2016-05-16 09:13:35 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 29 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 31 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 33 2016-05-16 09:12:32 is greater than a week from 2016-05-16 12:13:35 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 29 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 31 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 33 2016-05-16 09:12:32 is greater than a week from 2016-05-18 09:13:35 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 29 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 31 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 33 2016-05-16 09:12:32 is greater than a week from 2016-07-16 09:13:35 Testing whilst looking at the both intervals: Warning: Cannot compare DateInterval objects in /in/TrPvp on line 29 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 31 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 33 2016-05-16 09:12:32 is greater than a week from 2016-05-16 09:13:35 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 29 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 31 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 33 2016-05-16 09:12:32 is greater than a week from 2016-05-16 12:13:35 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 29 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 31 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 33 2016-05-16 09:12:32 is greater than a week from 2016-05-18 09:13:35 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 29 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 31 Warning: Cannot compare DateInterval objects in /in/TrPvp on line 33 2016-05-16 09:12:32 is greater than a week from 2016-07-16 09:13:35

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:
70.77 ms | 413 KiB | 8 Q