3v4l.org

run code in 500+ PHP versions simultaneously
<?php function timeBetween(string $dob): array { $DAYS_IN_YEAR = 365; $DAYS_IN_WEEK = 7; $now = new DateTime(); // now $birthDate = new DateTime($dob); $totalDays = $now->diff($birthDate)->days; return array( 'Year(s)' => (int)floor($totalDays/$DAYS_IN_YEAR), 'Week(s)' => (int)floor(($totalDays % $DAYS_IN_YEAR) / $DAYS_IN_WEEK), 'Day(s)' => (int)($totalDays % $DAYS_IN_YEAR) % $DAYS_IN_WEEK ); } function timeBetweenToString(array $timeBetween): string { $JOIN_PHRASE = ', and '; $timeBetween = array_filter($timeBetween); $result = array_reduce(array_keys($timeBetween), function ($results, $key) use ($timeBetween) { $value = $timeBetween[$key]; $results[] = "$value $key"; return $results; }, []); return implode($JOIN_PHRASE, $result); } $people = []; $people[] = array('name' => 'Bob', 'bday' => '2000-02-17'); $people[] = array('name' => 'Jane', 'bday' => '2005-03-30'); $people[] = array('name' => 'Mark', 'bday' => '2011-12-05'); foreach($people as $value) { echo "{$value['name']} was born " . timeBetweenToString(timeBetween($value['bday'])) . " ago\n"; }

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.5.80.0120.00716.77
8.5.70.0240.01118.74
8.5.60.0050.00418.75
8.5.50.0130.00316.69
8.5.40.0160.00317.00
8.5.30.0190.00316.42
8.5.20.0220.00616.93
8.5.10.0240.00516.75
8.5.00.0190.00416.71
8.4.230.0160.00719.73
8.4.220.0340.00719.39
8.4.210.0160.00919.89
8.4.200.0280.00519.54
8.4.190.0290.00719.61
8.4.180.0200.00619.46
8.4.170.0140.00619.59
8.4.160.0180.00419.69
8.4.150.0140.00419.53
8.4.140.0160.00417.78
8.4.130.0120.00817.88
8.4.120.0190.00317.90
8.4.110.0180.00517.71
8.4.100.0170.00417.99
8.4.90.0250.00417.67
8.4.80.0230.00317.93
8.4.70.0170.00417.72
8.4.60.0190.00817.96
8.4.50.0160.00617.78
8.4.40.0160.00517.81
8.4.30.0150.00617.85
8.4.20.0170.00317.66
8.4.10.0170.00517.87
8.3.320.0080.00320.40
8.3.310.0160.00218.64
8.3.300.0130.00520.33
8.3.290.0140.00418.58
8.3.280.0150.00420.27
8.3.270.0140.00516.72
8.3.260.0150.00416.68
8.3.250.0190.00116.91
8.3.240.0140.00416.93
8.3.230.0150.00416.45
8.3.220.0150.00518.59
8.3.210.0190.00718.38
8.3.200.0150.00616.64
8.3.190.0230.00016.62
8.3.180.0190.01016.70
8.3.170.0170.00416.88
8.3.160.0180.00716.74
8.3.150.0350.00616.56
8.3.140.0180.01016.71
8.3.130.0160.00416.55
8.3.120.0180.00216.65
8.3.110.0130.00516.64
8.3.100.0160.00416.71
8.3.90.0170.00516.79
8.3.80.0140.00616.58
8.3.70.0210.00416.84
8.3.60.0160.00416.82
8.3.50.0150.00516.84
8.3.40.0190.00718.23
8.3.30.0100.00618.10
8.3.20.0120.00517.99
8.3.10.0120.00418.10
8.3.00.0160.00618.07
8.2.320.0260.00619.95
8.2.310.0160.00718.34

preferences:
58.81 ms | 772 KiB | 5 Q